Closed ydah closed 4 months ago
As far as I can tell, this is the current state of autocorrection for the different cops, sorted by “Always”, “Always (unsafe)”, “No”:
Always
Always (Unsafe)
No
Should we start listing which ones we want to be contextual?
Basically, I think always
is fine. So, let's list only the obvious annoyances like RSpec/Focus
as a contextual
list. If the cop that requires contextual
is not contextual
, it doesn't break the existing behavior. WDYT?
What about cops like RSpec/ScatteredLet and RSpec/ScatteredSetup, wouldn’t they potentially move the code a person is currently editing?
Hold on, when are LSP corrections applied? Only when a file is saved, right?
https://github.com/rubocop/rubocop/pull/12657 says
This PR introduces
AutoCorrect: contextual
option that prevents autocorrection during typing in LSP.
which seems to suggest corrections are applied before saving, while still typing.
I think the automatic correction is done when saving to a file. I think the following Finish Editing
is what happens when you save a file:
https://speakerdeck.com/koic/rubocop-lsp-and-prism?slide=62
For example, if
RSpec/Focus
is enabled, we will always havefocus
removed by the LSP. https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecfocus