Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a false positive for Layout/EmptyLinesAroundAccessModifier #8756

Commits on Sep 21, 2020

  1. Fix a false positive for Layout/EmptyLinesAroundAccessModifier

    This PR fixes the following infinite loop error for
    `Layout/EmptyLinesAroundAccessModifier` with `Layout/EmptyLinesAroundBlockBody`
    when using access modifier with block argument.
    
    ```console
    % cat example.rb
    FactoryBot.define do
      factory :model do
        name { 'hoge' }
    
        private { true }
      end
    end
    
    % rubocop -a --only Layout/EmptyLinesAroundAccessModifier,Layout/EmptyLinesAroundBlockBody
    (snip)
    
    Inspecting 1 file
    C
    
    Offenses:
    
    example.rb:5:5: C: [Corrected] Layout/EmptyLinesAroundAccessModifier:
    Keep a blank line before and after private.
        private { true }
        ^^^^^^^
    example.rb:6:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra
    empty line detected at block body end.
    
    0 files inspected, 2 offenses detected, 2 offenses corrected
    Infinite loop detected in
    /Users/koic/src/github.com/koic/rubocop-issues/factory_bot/example.rb
    and caused by Layout/EmptyLinesAroundAccessModifier -> Layout/EmptyLinesAroundBlockBody
    ```
    koic committed Sep 21, 2020
    Copy the full SHA
    e753311 View commit details
    Browse the repository at this point in the history