Skip to content

Commit

Permalink
[Fix #8232] Fix a false positive for `Layout/EmptyLinesAroundAccessMo…
Browse files Browse the repository at this point in the history
…difier`

Fixes #8232.

This PR fixes a false positive and an incorrect auto-correct for
`Layout/EmptyLinesAroundAccessModifier` when `end` immediately
after access modifier.
  • Loading branch information
koic authored and bbatsov committed Jul 8, 2020
1 parent 501640d commit 12356cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@

* [#8242](https://github.com/rubocop-hq/rubocop/pull/8242): Internal profiling available with `bin/rubocop-profile` and rake tasks. ([@marcandre][])

### Bug fixes

* [#8232](https://github.com/rubocop-hq/rubocop/issues/8232): Fix a false positive for `Layout/EmptyLinesAroundAccessModifier` when `end` immediately after access modifier. ([@koic][])

## 0.87.1 (2020-07-07)

### Bug fixes
Expand Down
Expand Up @@ -109,6 +109,7 @@ def autocorrect(node)

def allowed_only_before_style?(node)
if node.special_modifier?
return true if processed_source[node.last_line] == 'end'
return false if next_line_empty?(node.last_line)
end

Expand Down
Expand Up @@ -397,6 +397,14 @@ def test; end
end
RUBY
end

it "does not register an offense when `end` immediately after #{access_modifier}" do
expect_no_offenses(<<~RUBY)
class Test
#{access_modifier}
end
RUBY
end
end

%w[public module_function].each do |access_modifier|
Expand Down

0 comments on commit 12356cb

Please sign in to comment.