Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
AutoCorrect: except_on_edit
option
## Summary This PR introduces `AutoCorrect: except_on_edit` option that prevents autocorrection during typing in LSP. This option extends the existing `AutoCorrect` parameter. - Before: `AutoCorrect: true` or `AutoCorrect: false` - After: `AutoCorrect: always`, `AutoCorrect: off`, or `AutoCorrect: except_on_edit` Note, `AutoCorrect: always` maintains compatibility with `AutoCorrect: true`, and `AutoCorrect: off` maintains compatibility with `AutoCorrect: false`. ## Details For example, `Style/EmptyMethod` should not autocorrect to one-liner while in the process of writing the body of the method. This isn't an issue with autocorrection itself, but rather due to differing requirements in contexts such as editing (LSP) and command line (e.g., CI). So, `AutoCorrect: except_on_edit` is set for some cops like this. There may be other cases, but for the obvious following cops. The classification is as follows: ### Cops that might remove code being edited - `Layout/EmptyComment` cop - `Lint/EmptyConditionalBody` cop - `Lint/EmptyEnsure` cop - `Lint/EmptyInterpolation` cop - `Lint/TrailingCommaInAttributeDeclaration` cop - `Lint/UselessAccessModifier` cop - `Lint/UselessAssignment` cop - `Lint/UselessMethodDefinition` cop - `Lint/UselessTimes` cop - `Lint/Void` cop - `Style/EmptyElse` cop - `Style/RedundantInitialize` cop ### Cops that might adjust code being edited - `Lint/UnusedBlockArgument` cop - `Lint/UnusedMethodArgument` cop - `Style/EmptyHeredoc` cop - `Style/EmptyMethod` cop As a result, it allows for a distinction in the use of autocorrection between the LSP and command-line contexts. ## Other Information Here is why the parameter name was chosen as `except_on_edit`. In this PR, autocorrection from LSP is always not applied in the case of `except_on_edit`. However, even when `except_on_edit` is set, I was considering a possibility for autocorrection to be forcibly applied from LSP under certain conditions. Therefore, the initial thought was to name it `except_on_lsp`, but it might have been too abstract in context, so it was changed to `except_on_edit`. Of course, `except_on_edit` may not be the best name. If there is a better suggestion for the parameter name, please propose it.
- Loading branch information
Showing
13 changed files
with
186 additions
and
28 deletions.
There are no files selected for viewing
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 @@ | ||
* [#12657](https://github.com/rubocop/rubocop/pull/12657): Support `AutoCorrect: except_on_edit` option. ([@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
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
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
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
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
Oops, something went wrong.