misogi / vscode-ruby-rubocop

Rubocop extension for Visual Studio Code
https://marketplace.visualstudio.com/items/misogi.ruby-rubocop
MIT License
137 stars 68 forks source link

Config option to surpress warnings #43

Open AndrewRayCode opened 7 years ago

AndrewRayCode commented 7 years ago

My .rubocop.yml has some obsolete params in it, and every time I open a .rb file in my vscode project, I get an error toast at the top of the page saying so. Can we add a config option to disable linting warnings in that file propagating to vscode, or somehow make it only show on first file open? Right now it's quite distracting.

damien commented 7 years ago

Hey @AndrewRayCode! I'm not the maintainer, but I do contribute to this repo. I'm currently working on getting Bundler integration working with this extension. Once that's done you should be able to pin your project to the version of Rubocop your config works with.

I think this should resolve your problem in addition to other issues that come up as a result of a version mismatch between the Rubocop binary and a project's Rubocop configuration. (see https://github.com/misogi/vscode-ruby-rubocop/issues/34 for the nitty gritty)

AndrewRayCode commented 7 years ago

No, pinning the rubocop version will not solve my problem.

damien commented 7 years ago

@AndrewRayCode I guess I don't understand what's going on here very well.

From what you've said, it sounds like you had a Rubocop config that was valid at some point, but is not valid with the version of Rubocop VSCode is attempting to analyze your ruby file with.

Is my understanding incorrect? Can you elaborate on what specific issues/errors you're seeing?

AndrewRayCode commented 7 years ago

Rubocop warnings should not be shown to the user. Rubocop still runs if there are warnings from the linting file. I may be locked in to a rubocop version or linting file that I can't control, and have no choice but to see and ignore warnings. Seeing a warning popup on every single tab I open (which covers tabs in vscode, hiding functionality) is the problem. I should be able to suppress these warnings, since rubocop works fine, or not see them at all.

damien commented 7 years ago

Ah, thanks for the context! That makes a lot of sense. this shouldn't be too hard to implement, and I've seen plenty of people at my own workplace having similar complaints about such rubocop warnings. :+1:

erikdstock commented 7 years ago

I was looking into this for a quick fix (it is very annoying) and found the point where rubocop emits the error: https://github.com/bbatsov/rubocop/blob/dcb3f160a2e23218a7826aadd0e64baefd6d7521/spec/rubocop/cop/registry_spec.rb#L99

There are other cases where a bad config file/cop name might emit an error, so I wasn't sure if just matching on phrases like has the wrong namespace - should be (my specific issue) would be enough. If anyone has advice on best ways to do this for a vscode extension i'd be happy to pick this up.