Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ```
- Loading branch information
Showing
3 changed files
with
9 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog/fix_incorrect_autocorrect_for_style_single_line_methods.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#9645](https://github.com/rubocop/rubocop/pull/9645): Fix an incorrect auto-correct for `Style/SingleLineMethods` when using single line class method definition. ([@koic][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters