Commit 3b189b3
committed
Add --editor-mode flag when invoking rubocop
Since RuboCop 1.61.0 (released in February 2024), RuboCop accepts an
`--editor-mode` flag which improves editor integrations like ale.
Some of RuboCop's auto-corrections can be surprising or annoying to run
on save. When RuboCop is running via an LSP or when the `--editor-mode`
flag is passed, it will understand that it is running in an editor, and
it will hold off on making changes that might be surprising or annoying.
For example, if I write
```ruby
def call
results = some_process
end
```
This has an unused variable, and RuboCop will remove the unused variable
when you run it. However, if you're in the middle of editing, you may
not want it to remove that unused variable, because you may be about to
add a usage of it.
More context:
- PR which introduced it: rubocop/rubocop#12682
- Release notes for 1.61: https://github.com/rubocop/rubocop/releases/tag/v1.61.0
- Docs: https://docs.rubocop.org/rubocop/1.80/configuration.html#contextual
This will be a breaking change for anyone who is running an old version
of RuboCop, because the flag will not exist for them. If they would like
to opt out of this change, they can set an option to omit the flag. I
think this ought to be enabled by default so that people will get this
benefit out of the box.
In the meantime, I am opting into this behavior by setting this option:
```vim
let g:ale_ruby_rubocop_options = "--editor-mode"
```
So I appreciate that this seam was already introduced.1 parent 4217461 commit 3b189b3
File tree
3 files changed
+30
-3
lines changed- autoload/ale/fixers
- doc
- test/fixers
3 files changed
+30
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
190 | 202 | | |
191 | 203 | | |
192 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
0 commit comments