Skip to content

Commit

Permalink
Allow non_bare_access_modifier_declaration? to handle modifiers wit…
Browse files Browse the repository at this point in the history
…h multiple arguments.
  • Loading branch information
dvandersluis authored and marcandre committed Nov 2, 2024
1 parent eb91347 commit 2515451
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@ RSpec/MultipleExpectations:
# URISchemes: http, https
Layout/LineLength:
Max: 102

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols, AllowModifiersOnAttrs.
# SupportedStyles: inline, group
Style/AccessModifierDeclarations:
Exclude:
- 'lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb'
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/mixin/method_dispatch_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def binary_operation?

# @!method non_bare_access_modifier_declaration?(node = self)
def_node_matcher :non_bare_access_modifier_declaration?, <<~PATTERN
(send nil? {:public :protected :private :module_function} _)
(send nil? {:public :protected :private :module_function} _+)
PATTERN
end
end
Expand Down
24 changes: 24 additions & 0 deletions spec/rubocop/ast/send_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ module Foo
it { expect(send_node).to be_access_modifier }
end

context 'when node is a non-bare `module_function` with multiple arguments' do
let(:source) do
<<~RUBY
module Foo
>> module_function :foo, :bar <<
end
RUBY
end

it { expect(send_node).to be_access_modifier }
end

context 'when node is not an access modifier' do
let(:source) do
<<~RUBY
Expand Down Expand Up @@ -209,6 +221,18 @@ module Foo
it { expect(send_node).to be_non_bare_access_modifier }
end

context 'when node is a non-bare `module_function` with multiple arguments' do
let(:source) do
<<~RUBY
module Foo
>> module_function :foo, :bar <<
end
RUBY
end

it { expect(send_node).to be_non_bare_access_modifier }
end

context 'when node does not have an argument' do
let(:source) do
<<~RUBY
Expand Down

0 comments on commit 2515451

Please sign in to comment.