Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update require statement in README #40

Closed

Conversation

swiknaba
Copy link

@swiknaba swiknaba commented Apr 6, 2019

Adding require: rubocop-performance on top of your rubocop yml will throw an exception:

Error running RuboCop Error: cannot load such file -- rubocop-performance ../2.5.0/rubygems/core_ext/kernel_require.rb:54:in require

The solution is to nest it under AllCops, the docs actually suggest that. Keys like Include/Exclude are all capitalized, so why not capitalize require as well?

I guess, there is no need to bump the version for this? (-:


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself and generates the documentation.

from the CI:

#!/bin/bash -eo pipefail
bundle exec rake
bundle exec rubocop
Inspecting 69 files
.....................................................................

69 files inspected, no offenses detected
Files:          30
Modules:         3 (    2 undocumented)
Classes:        30 (    0 undocumented)
Constants:      54 (   49 undocumented)
Attributes:      0 (    0 undocumented)
Methods:        61 (   55 undocumented)
 28.38% documented
rake aborted!
RuboCop::ValidationError: The `Performance/LstripRstrip` cop has been moved to `Style/Strip`
(obsolete configuration found in config/default.yml, please update it)
/usr/local/bundle/gems/rubocop-0.67.2/lib/rubocop/config.rb:560:in `reject_obsolete_cops_and_parameters'
/usr/local/bundle/gems/rubocop-0.67.2/lib/rubocop/config.rb:363:in `validate'
/usr/local/bundle/gems/rubocop-0.67.2/lib/rubocop/config.rb:249:in `check'
/usr/local/bundle/gems/rubocop-0.67.2/lib/rubocop/config.rb:242:in `create'
/usr/local/bundle/gems/rubocop-0.67.2/lib/rubocop/config_loader.rb:53:in `load_file'
tasks/cops_documentation.rake:248:in `main'
tasks/cops_documentation.rake:260:in `block in <top (required)>'
/usr/local/bundle/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => default => generate_cops_documentation
(See full trace by running task with --trace)
Exited with code 1

Adding `require: rubocop-performance` on top of your rubocop yml will throw an exception:
```
Error running RuboCop Error: cannot load such file -- rubocop-performance ../2.5.0/rubygems/core_ext/kernel_require.rb:54:in require
```
The solution is to nest it under `AllCops`, the [docs](https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md#includingexcluding-files) actually suggest that. Keys like `Include`/`Exclude` are all capitalized, so why not capitalize `require` as well?
@swiknaba swiknaba changed the title Update README.md Update require statement in README Apr 6, 2019
@koic
Copy link
Member

koic commented Apr 8, 2019

I think that the README is correct as it is used in the RuboCop Core config.
https://github.com/rubocop-hq/rubocop/blob/98c30a60fb5133e0f31d5b23587ab9c1baf5118f/.rubocop.yml#L4-L9

Is gem 'rubocop-performance' written in Gemfile? The following document may also be helpful.
https://github.com/rubocop-hq/rubocop/blob/98c30a60fb5133e0f31d5b23587ab9c1baf5118f/manual/migrate_performance_cops.md

Earlier RuboCop Performance 1.1.0 was released. Can you try it after running bundle udpate?

@Alpenglow88
Copy link

Alpenglow88 commented Apr 8, 2019

Using RuboCop Performance v 1.1.0 I too get cannot load such file -- rubocop-performance when adding require: rubocop-performance on top of my rubocop.yml

Regardless of capitalisation, when I have

require:
- rubocop-performance

nested in AllCops then I see

Warning: AllCops does not support Require parameter.
Supported parameters are:...

But it does successfully run through my CI.

That doesn't feel like the most elegant solution to the problem as the same result can be achieved by just not adding the required line to the rubocop.yml and then my CI runs through fine - also works fine with a manual rubocop from my terminal.

Does this even need to be add to the yml at all?

@swiknaba
Copy link
Author

swiknaba commented Apr 8, 2019

Thank you for your fast reply and the links, koic!

This is the error in the Atom-console:

/Users/me/.atom/packages/linter/lib/linter-registry.js:155 [Linter] Error running RuboCop Error: cannot load such file -- rubocop-performance
/Users/me/.rbenv/versions/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/config_loader_resolver.rb:15:in `block in resolve_requires'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/config_loader_resolver.rb:11:in `each'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/config_loader_resolver.rb:11:in `resolve_requires'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/config_loader.rb:44:in `load_file'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/config_loader.rb:82:in `configuration_from_file'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/config_store.rb:44:in `for'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/target_finder.rb:183:in `block in process_explicit_path'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/target_finder.rb:182:in `reject'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/target_finder.rb:182:in `process_explicit_path'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/target_finder.rb:39:in `block in find'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/target_finder.rb:35:in `each'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/target_finder.rb:35:in `find'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/runner.rb:64:in `find_target_files'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/runner.rb:34:in `run'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/cli.rb:174:in `execute_runner'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/cli.rb:75:in `execute_runners'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/lib/rubocop/cli.rb:47:in `run'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/exe/rubocop:25:in `block in <top (required)>'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
/Users/me/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rubocop-0.67.2/exe/rubocop:24:in `<top (required)>'
/Users/me/.rbenv/versions/2.5.3/bin/rubocop:23:in `load'
/Users/me/.rbenv/versions/2.5.3/bin/rubocop:23:in `<main>'
    at parseFromStd (/Users/me/.atom/packages/linter-rubocop/src/index.js:59:43)
    at Object.<anonymous> (/Users/me/.atom/packages/linter-rubocop/src/index.js:287:27)
    at Generator.next (<anonymous>)
    at step (/Users/me/.atom/packages/linter-rubocop/src/index.js:9:273)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

.rubocop.yml:

require:
  - rubocop-rspec
  - rubocop-performance

AllCops:
  Exclude:
    - 'vendor/**/*'
    - 'spec/fixtures/**/*'
    - 'tmp/**/*'
    - 'db/**/*'
    - 'lib/**/*'
  TargetRubyVersion: 2.6.2

-> Before I only required: rubocop-rspec, which worked fine.

Yes, it is inside the Gemfile, and installed via bundler:

ruby '2.6.2'
gem 'rails', '~> 5.2', '>= 5.2.3'
gem 'rubocop'
gem 'rubocop-performance', '~> 1.0'
gem 'rubocop-rspec'

the .lock file:

    rubocop (0.67.2)
      (...)
    rubocop-performance (1.1.0)
      rubocop (>= 0.67.0)
    rubocop-rspec (1.32.0)
      rubocop (>= 0.60.0)

Upgraded to 1.1.0, the problem persists.

@koic
Copy link
Member

koic commented Apr 10, 2019

Does this even need to be add to the yml at all?

RuboCop core has Performance cops until RuboCop 0.67.2. It will be removed in the next release RuboCop 0.68.
rubocop/rubocop#6845

RuboCop 0.67 series are the transition period. So RuboCop 0.67.2 works without require: - rubocop-performance in .rubocop.yml, but RuboCop 0.68 will required it when using Performance cops.

This is the error in the Atom-console:

I'm not familiar with it because I'm not using Atom editor... The following issue can be a hint?
AtomLinter/linter-rubocop#309

@swiknaba
Copy link
Author

Thank you very much for your help! 🙂

So one should remove the require statement for 0.67.2, when 0.68 is released, add it back, if the Atom-linter is still failing, that seems to be a problem of the RuboCop-linter plugin of Atom and has to be fixed there, if I understand the discussion from your last link correctly.

@swiknaba swiknaba closed this Apr 10, 2019
@swiknaba swiknaba deleted the swiknaba-readme-require-statement branch April 10, 2019 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants