Open RichardsonWTR opened 3 years ago
I'm unable to set SuggestExtensions: false
, because when I do that, it complains:
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
It seems like this is triggered by the presence of a .rubocop.yml
file.
We want default rubocop behavior because we can't justify writing a config file for this project (ruby is not our main language) so I'm looking for a way to workaround this bug without having a .rubocop.yml
file.
@cspotcode the message you're getting is due to RuboCop marking new cops as pending between major releases. You can choose to automatically enable or disable them by default in your .rubocop.yml
along with SuggestExtensions: false
, which will continue to use the default rubocop configuration but remove the warning messages you're experiencing):
AllCops:
NewCops: [enable|disable] # choose one
SuggestExtensions: false
See https://docs.rubocop.org/rubocop/1.6/versioning.html for more details.
The bug here is that those messages should not be written into the .rb source file. The extension is writing them into the .rb source file, meaning that attempting to save an .rb file causes the editor to append invalid syntax, (those messages) breaking the file.
Diagnostic, warning, and error messages should be displayed in VSCode's interface, not written into source code. If the existence of those messages makes it impossible to format a file, then the file should remain unmodified.
On Mon, Dec 21, 2020, 1:54 AM Daniel Vandersluis notifications@github.com wrote:
@cspotcode https://github.com/cspotcode the message you're getting is due to RuboCop marking new cops as pending between major releases. You can choose to automatically enable or disable them by default in your .rubocop.yml along with SuggestExtensions: false, which will continue to use the default rubocop configuration but remove the warning messages you're experiencing):
AllCops: NewCops: [enable|disable] # choose one SuggestExtensions: false
See https://docs.rubocop.org/rubocop/1.6/versioning.html for more details.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/misogi/vscode-ruby-rubocop/issues/138#issuecomment-748799337, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC35OHDJY6CM74RWQ7RFT3SV3WJPANCNFSM4UMRHOZQ .
I had the same problem.
I have the same problem. The time I am saving thanks to rubocop I am wasting because of the garbage it writes to .rb files.
This is not a RuboCop bug, but rather a bug of how this library is calling RuboCop. The suggested extensions text only is added when using a formatter that is intended for human consumption. If this library used a RuboCop formatter meant for parsing (-f j
for json for instance), the text would not be output by RuboCop and then added to your code.
So it seems like this is a bug that breaks the extension. Is there a fix? From this code which sets the args and the --help
output below it seems the answer may be to set an additional --stderr
flag:
--stderr Write all output to stderr except for the
autocorrected source. This is especially useful
when combined with --auto-correct and --stdin.
...
-s, --stdin FILE Pipe source from STDIN, using FILE in offense
reports. This is useful for editor integration.
I can't work on this right now so am just going to disable the suggested extensions.
After upgrading to 1.5.1, Rubocop by default prints the following message in the console when you run the command:
This exact message appears at the end of every file when I save using the auto formatting in the VSCode Extension.
Versions
Relevant VSCode preferences
Setting the option
SuggestExtensions: false
as showed by Rubocop fixes the issue; for now.