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 an incorrect auto-correct for Style/StructInheritance #8443

Commits on Aug 3, 2020

  1. Fix an incorrect auto-correct for Style/StructInheritance

    This PR fixes the following incorrect auto-correct for `Style/StructInheritance`
    incorrect auto-correct for `Style/StructInheritance` when there is a comment
    before class declaration.
    
    ```console
    % cat example.rb
    # comment
    class Foo < Struct.new(:foo)
    end
    
    % bundle exec rubocop --only Style/StructInheritance -a
    (snip)
    
    Offenses:
    
    example.rb:2:13: C: [Corrected] Style/StructInheritance: Don't extend an
    instance initialized by Struct.new. Use a block to customize the struct.
    class Foo < Struct.new(:foo)
                ^^^^^^^^^^^^^^^^
    
    1 file inspected, 1 offense detected, 1 offense corrected
    
    % cat example.rb
    # commentFoo = Struct.new(:foo) do
    end
    ```
    
    This issue has been reported on rubocop-jp. (Japanese)
    rubocop/rubocop-jp#61
    koic committed Aug 3, 2020
    Copy the full SHA
    3c51fb3 View commit details
    Browse the repository at this point in the history