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/DefEndAlignment #8653

Merged

Commits on Sep 5, 2020

  1. Fix a false positive for Layout/DefEndAlignment

    This PR fixes a false positive for `Layout/DefEndAlignment`
    when using refinements and `private def`.
    It prevents the following error when auto-correcting.
    
    ```console
    % cat example.rb
    using Module.new {
      refine Hash do
            class << Hash
          private def _ruby2_keywords_hash(*args)
          end
        end
      end
    }
    
    % bundle exec rubocop -a --only Layout/DefEndAlignment example.rb
    (snip)
    
    Inspecting 1 file
    W
    
    Offenses:
    
    example.rb:5:7: W: [Corrected] Layout/DefEndAlignment: end at 5, 6 is
    not aligned with using Module.new {
      refine Hash do
            class << Hash
          private def at 1, 0.
          end
          ^^^
    
    0 files inspected, 1 offense detected, 1 offense corrected
    Infinite loop detected in
    /Users/koic/src/github.com/koic/rubocop-issues/rails/example.rb.
    /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:289:in
    `check_for_infinite_loop'
    /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:272:in
    `block in iterate_until_no_changes'
    /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:271:in
    `loop'
    /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:271:in
    `iterate_until_no_changes'
    /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/runner.rb:242:in
    `do_inspection_loop'
    ```
    
    I found it with the following code.
    https://github.com/rails/rails/blob/v6.0.3.2/activejob/lib/active_job/arguments.rb#L73-L96
    koic committed Sep 5, 2020
    Copy the full SHA
    52f7b83 View commit details
    Browse the repository at this point in the history