question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rubocop TIP output is going to files on auto save

See original GitHub issue

After upgrading to 1.5.1, Rubocop by default prints the following message in the console when you run the command:

Tip: Based on detected gems, the following RuboCop extension libraries might be helpful:
  * rubocop-rails (http://github.com/rubocop-hq/rubocop-rails)
  * rubocop-rspec (http://github.com/rubocop-hq/rubocop-rspec)

You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options):
  AllCops:
    SuggestExtensions: false

This exact message appears at the end of every file when I save using the auto formatting in the VSCode Extension.

Versions

  • Ruby 2.5.1p57 (2018-03-29 revision 63029)
  • gem Rubocop: ~> 1.5.1
  • VSCode
Version: 1.51.1
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-10T23:31:29.624Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 4.15.0-118-generic
  • ruby-rubocop: 0.8.5

Relevant VSCode preferences

{
    "ruby.format": "rubocop",
    "editor.formatOnSave": true,
    "editor.formatOnSaveTimeout": 5000,
    "[ruby]": {
        "editor.defaultFormatter": "misogi.ruby-rubocop"
    },
    "ruby.rubocop.useBundler": true,
}

Setting the option SuggestExtensions: false as showed by Rubocop fixes the issue; for now.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
cspotcodecommented, Dec 21, 2020

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 .

1reaction
dvandersluiscommented, Apr 18, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Rubocop TIP output is going to files on auto save -
Rubocop TIP output is going to files on auto save. ... After upgrading to 1.5.1, Rubocop by default prints the following message in...
Read more >
vscode( vscode-ruby + rubocop ) how to auto correct on save?
Question. I was under the inpression that vscode-ruby and rubocop would auto-correct indentations and cop rules on file save, but apparently it ...
Read more >
Basic Usage :: RuboCop Docs
Run all cops enabled by configuration except the specified cop(s) and/or departments. --exclude-limit. Limit how many individual files --auto-gen-config can ...
Read more >
Rubocop - 4 ways to reduce your frustration! | Hanami Mastery
In this episode, I'll show you how to keep it only in the loved section. ... Rubocop Allows you to automatically generate a...
Read more >
How to Use Rubocop for Your Team's Rails Apps - Semaphore
Rubocop gets its configuration from the automatically generated .rubocop.yml file. If you've already run Rubocop with --auto-gen-config , then ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found