Search code examples
ruby-on-railsvisual-studio-coderubocop

Warning: unrecognized cop Rails/


I have problems with Rubocop in Vs-code. I get the error

Warning: unrecognized cop Rails/ActionFilter found in /path/to/yml/with/cops
...
Warning: unrecognized cop Rails/Output found in
...
Warning: unrecognized cop Rails/UnknownEnv found in
...
# The list goes on...

I run:

Rubocop version rubocop-0.76.0

VS-code Version: 1.39.2

ruby-rubocop extention in vs code: 0.8.1

macOS Catalina: 10.15 (Problem existed in earlier versions like mojave)


I find very little about this problem. Basically only thing I found was this. And I already have require rubocop-rspec in my rspec yml file so no success with the proposals from that thread.

What can I do to solve this? My co-workers will soon start to call me Mr. Lint-failure


Solution

  • It seems like rubocop warnings is preventing rubocop to finish. In your version of rubocop there should be a setting called suppressRubocopWarnings try checking that if you know that the warnings doesn't need to be handled.

    You can do that by typing cmd+shift+p and type Open User Settings. There you can search for rubocop and check the suppressRubocopWarnings checkbox, restart VSCode and it should work.

    If you are using an older version of VSCode without the fancy UI, you should be able to add "ruby.rubocop.suppressRubocopWarnings": true, in your user settings json.

    It seems to be common to get these kind of warnings if you share a rubocop.yml file across multiple projects.

    Source: https://github.com/misogi/vscode-ruby-rubocop/pull/97