diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2aa934c16..5f2557d1a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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' diff --git a/lib/rubocop/ast/node/mixin/method_dispatch_node.rb b/lib/rubocop/ast/node/mixin/method_dispatch_node.rb index b86006783..40e484ad3 100644 --- a/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +++ b/lib/rubocop/ast/node/mixin/method_dispatch_node.rb @@ -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 diff --git a/spec/rubocop/ast/send_node_spec.rb b/spec/rubocop/ast/send_node_spec.rb index bb77fe52c..c32f1a3e7 100644 --- a/spec/rubocop/ast/send_node_spec.rb +++ b/spec/rubocop/ast/send_node_spec.rb @@ -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 @@ -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