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/SingleLineMethods #9645

Commits on Mar 29, 2021

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

    Fix the following incorrect auto-correct for `Style/SingleLineMethods`
    when using single line class method definition.
    
    ```console
    % cat example.rb
    def self.some_method; body end
    
    % rubocop --only Style/SingleLineMethods -a
    (snip)
    
    Offenses:
    
    example.rb:1:1: C: [Corrected] Style/SingleLineMethods: Avoid
    single-line method definitions.
    def self.some_method; body end
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    1 file inspected, 1 offense detected, 1 offense corrected
    ```
    
    ## Before
    
    ```console
    % cat example.rb
    def some_method() = body
    ```
    
    `self` is lost due to auto-correction.
    
    ## After
    
    ```console
    % cat example.rb
    def self.some_method() = body
    ```
    koic committed Mar 29, 2021
    Copy the full SHA
    cf166e2 View commit details
    Browse the repository at this point in the history