Skip to content

Commit

Permalink
[Fix #5953] Fix a false positive for Style/AccessModifierDeclarations
Browse files Browse the repository at this point in the history
Fixes #5953.

This PR fixes a false positive for `Style/AccessModifierDeclarations`
when using `module_function` with symbol.
  • Loading branch information
koic committed Mar 23, 2021
1 parent 98ff684 commit c5913b3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
@@ -0,0 +1 @@
* [#5953](https://github.com/rubocop/rubocop/issues/5953): Fix a false positive for `Style/AccessModifierDeclarations` when using `module_function` with symbol. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/access_modifier_declarations.rb
Expand Up @@ -79,7 +79,7 @@ class AccessModifierDeclarations < Base

# @!method access_modifier_with_symbol?(node)
def_node_matcher :access_modifier_with_symbol?, <<~PATTERN
(send nil? {:private :protected :public} (sym _))
(send nil? {:private :protected :public :module_function} (sym _))
PATTERN

def on_send(node)
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cop/style/access_modifier_declarations_spec.rb
Expand Up @@ -46,7 +46,7 @@ class Foo
}
end

%w[private protected public].each do |access_modifier|
%w[private protected public module_function].each do |access_modifier|
it "offends when #{access_modifier} is inlined with a method" do
expect_offense(<<~RUBY, access_modifier: access_modifier)
class Test
Expand Down Expand Up @@ -108,7 +108,7 @@ class TestThree
}
end

%w[private protected public].each do |access_modifier|
%w[private protected public module_function].each do |access_modifier|
it "offends when #{access_modifier} is not inlined" do
expect_offense(<<~RUBY, access_modifier: access_modifier)
class Test
Expand Down

0 comments on commit c5913b3

Please sign in to comment.