SublimeLinter / SublimeLinter-rubocop

SublimeLinter 3 plugin for Ruby, using rubocop.
MIT License
159 stars 40 forks source link

Should this linter be compatible with the `rubocp-rails` and `rubocop-performance` gems? #69

Closed GregSmith92 closed 4 years ago

GregSmith92 commented 4 years ago

I have a rails project which uses the gems 'rubocop', 'rubocop-rails' and 'rubocop-performance'.

The sublimeLinter does not work when the later two gems are required in the .rubocop.yml file.

If I enable debugging I get an error in the console:

cannot load such file -- rubocop-rails

or

uninitialized constant RuboCop::Cop::Performance::Count::SafeMode

depending on which require is left in the file.

It is only when I remove these from the .rubocop.yml file does the linter start working when I am writing code. It wouldn't be so bad if if just didn't show errors from style faults related to these gems, but it stops ordinary rubocop errors from displaying.

Is there a workaround for this? Many thanks

kaste commented 4 years ago

Generally, if it works on the command line there is a good chance it will work in Sublime.

Having debug on, you should see which command we run here plus the working dir. Does that work on the command line, or can you change it on the command line to something that just works?

GregSmith92 commented 4 years ago

This is the full console error log when I change an .rb file.

  /Users/gregsmith/code/GregSmith92/elvinyl  (working dir)
  $ cat app/controllers/admin/archive_items_controller.rb | /Users/gregsmith/.rbenv/shims/rubocop --format emacs --force-exclusion --stdin /Users/gregsmith/code/GregSmith92/elvinyl/app/controllers/admin/archive_items_controller.rb

SublimeLinter: #10232 linter.py:786   WARNING: rubocop output:
uninitialized constant RuboCop::Cop::Performance::Count::SafeMode
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.4.0/lib/rubocop/cop/performance/count.rb:41:in `<class:Count>'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.4.0/lib/rubocop/cop/performance/count.rb:40:in `<module:Performance>'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.4.0/lib/rubocop/cop/performance/count.rb:5:in `<module:Cop>'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.4.0/lib/rubocop/cop/performance/count.rb:4:in `<module:RuboCop>'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.4.0/lib/rubocop/cop/performance/count.rb:3:in `<top (required)>'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.4.0/lib/rubocop/cop/performance_cops.rb:15:in `require_relative'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.4.0/lib/rubocop/cop/performance_cops.rb:15:in `<top (required)>'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.4.0/lib/rubocop-performance.rb:11:in `require_relative'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.4.0/lib/rubocop-performance.rb:11:in `<top (required)>'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/config_loader_resolver.rb:11:in `each'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/config_loader.rb:45:in `load_file'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/config_loader.rb:86:in `configuration_from_file'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/config_store.rb:44:in `for'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/target_finder.rb:180:in `block in process_explicit_path'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/target_finder.rb:179:in `reject'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/target_finder.rb:179:in `process_explicit_path'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/target_finder.rb:39:in `block in find'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/target_finder.rb:35:in `each'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/target_finder.rb:35:in `find'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/runner.rb:64:in `find_target_files'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/runner.rb:34:in `run'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/cli/command.rb:10:in `run'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/cli/environment.rb:17:in `run'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/cli.rb:65:in `run_command'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/cli.rb:72:in `execute_runners'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/lib/rubocop/cli.rb:41:in `run'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/exe/rubocop:13:in `block in <top (required)>'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
/Users/gregsmith/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.80.1/exe/rubocop:12:in `<top (required)>'
/Users/gregsmith/.rbenv/versions/2.6.3/bin/rubocop:23:in `load'
/Users/gregsmith/.rbenv/versions/2.6.3/bin/rubocop:23:in `<main>'

SublimeLinter: #10232 linter.py:788   Note: above warning will become an error in the future. Implement `on_stderr` if you think this is wrong.
SublimeLinter: #10232 linter.py:1196  rubocop: no output
SublimeLinter: sublime_linter.py:575  Linting 'archive_items_controller.rb' took 0.93s
kaste commented 4 years ago

This is completely different output from your first post. How's that? You also don't discuss if the command we run looks sane, and if it works on the command line/your Terminal. From what I can see you must update rubocop-performance.

GregSmith92 commented 4 years ago

In the first post I showed only the hesdline error: uninitialized constant RuboCop::Cop::Performance::Count::SafeMode which is at the top of the longer log I just posted.

That is a good spot that rubocop-performance is using version 1.4.0. I have version 1.5.2 in the project gem file. From this I assume there is a separate place this must be updated to be used by the linter.

And sorry, I wasn't sure exactly what you meant with checking if the command looks sane.

If you mean is there a response in the terminal when I run the same command, then the same output error I posted above is returned there too.

Thanks for your help

GregSmith92 commented 4 years ago

Turned out rubocop-rails was not present in my .rbenv and rubocop-performance needed updating as you pointed out. Thanks a lot for pointing that out

kaste commented 4 years ago

Computers 🤪🤷