Skip to content

Commit

Permalink
Merge pull request #8427 from koic/fix_error_for_lint_ineffective_acc…
Browse files Browse the repository at this point in the history
…ess_modifier

[Fix #8424] Fix an error for `Lint/IneffectiveAccessModifier`
  • Loading branch information
koic committed Jul 31, 2020
2 parents cad8d8a + 304a464 commit 10cedb8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -31,6 +31,7 @@
* [#8330](https://github.com/rubocop-hq/rubocop/issues/8330): Fix a false positive for `Style/MissingRespondToMissing` when defined method with inline access modifier. ([@koic][])
* [#8422](https://github.com/rubocop-hq/rubocop/issues/8422): Fix an error for `Lint/SelfAssignment` when using or-assignment for constant. ([@koic][])
* [#8423](https://github.com/rubocop-hq/rubocop/issues/8423): Fix an error for `Style/SingleArgumentDig` when without a receiver. ([@koic][])
* [#8424](https://github.com/rubocop-hq/rubocop/issues/8424): Fix an error for `Lint/IneffectiveAccessModifier` when there is `begin...end` before a method definition. ([@koic][])

### Changes

Expand Down
4 changes: 1 addition & 3 deletions lib/rubocop/cop/lint/ineffective_access_modifier.rb
Expand Up @@ -96,9 +96,7 @@ def format_message(modifier)
end

# rubocop:disable Metrics/CyclomaticComplexity
def ineffective_modifier(node, modifier = nil, &block)
ignored_methods = nil

def ineffective_modifier(node, ignored_methods = nil, modifier = nil, &block)
node.each_child_node do |child|
case child.type
when :send
Expand Down
14 changes: 14 additions & 0 deletions spec/rubocop/cop/lint/ineffective_access_modifier_spec.rb
Expand Up @@ -118,4 +118,18 @@ def self.method
RUBY
end
end

context 'when there is `begin` before a method definition' do
it 'does not register an offense' do
expect_no_offenses(<<~RUBY)
class C
begin
end
def do_something
end
end
RUBY
end
end
end

0 comments on commit 10cedb8

Please sign in to comment.