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
RuboCop is a Ruby static code analyzer (a.k.a. linter ) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. Apart from reporting the problems discovered in your code, RuboCop can also automatically fix many of them for you.
Rubocop is a code analyzer and code formatter. This tool will apply recommended guidelines from the ([Ruby Style Guide])(https://github.com/rubocop-hq/ruby-style-guide). We encourage all Rails projects to adopt this tool.
Just in case you happened to copy the .rubocop.yml
file from a different project like I did, in my case I just forgot to add the rubocop-rails gem, which includes the Rails/ cops.
Install it like any other gem and and require it in your .rubocop.yml
file:
# Gemfile
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
$ bundle install
# .rubocop.yml
require: rubocop-rails
$ rubocop
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With