Skip to content

Commit

Permalink
Merge pull request #8933 from matthieugendreau/fix_an_error_for_layou…
Browse files Browse the repository at this point in the history
…t_empty_lines_around_access_modifier

Fix an error for Layout/EmptyLinesAroundAccessModifier
  • Loading branch information
koic committed Oct 24, 2020
2 parents c932483 + bbc48b6 commit e2db31d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@
* [#8913](https://github.com/rubocop-hq/rubocop/pull/8913): Fix an incorrect auto-correct for `Style/RedundantRegexpCharacterClass` due to quantifier. ([@ysakasin][])
* [#8917](https://github.com/rubocop-hq/rubocop/issues/8917): Fix rubocop comment directives handling of cops with multiple levels in department name. ([@fatkodima][])
* [#8918](https://github.com/rubocop-hq/rubocop/issues/8918): Fix a false positives for `Bundler/DuplicatedGem` when a gem conditionally duplicated within `if-elsif` or `case-when` statements. ([@fatkodima][])
* [#8933](https://github.com/rubocop-hq/rubocop/pull/8933): Fix an error for `Layout/EmptyLinesAroundAccessModifier` when the first line is a comment. ([@matthieugendreau][])

### Changes

Expand Down Expand Up @@ -5026,3 +5027,4 @@
[@AllanSiqueira]: https://github.com/allansiqueira
[@zajn]: https://github.com/zajn
[@ysakasin]: https://github.com/ysakasin
[@matthieugendreau]: https://github.com/matthieugendreau
Expand Up @@ -141,6 +141,7 @@ def previous_line_ignoring_comments(processed_source, send_line)
def previous_line_empty?(send_line)
previous_line = previous_line_ignoring_comments(processed_source,
send_line)
return true unless previous_line

block_start?(send_line) ||
class_def?(send_line) ||
Expand Down
11 changes: 11 additions & 0 deletions spec/rubocop/cop/layout/empty_lines_around_access_modifier_spec.rb
Expand Up @@ -213,6 +213,17 @@ def test
RUBY
end

it 'accepts missing blank line when at the beginning of file' \
'and preceded by a comment' do
expect_no_offenses(<<~RUBY)
# comment
#{access_modifier}
def do_something
end
RUBY
end

context 'at the beginning of block' do
context 'for blocks defined with do' do
it 'accepts missing blank line' do
Expand Down

0 comments on commit e2db31d

Please sign in to comment.