Skip to content

Instantly share code, notes, and snippets.

@phansch
Last active July 17, 2017 19:16
Show Gist options
  • Save phansch/770199131f86380b648d44c1f282564d to your computer and use it in GitHub Desktop.
Save phansch/770199131f86380b648d44c1f282564d to your computer and use it in GitHub Desktop.

Things to check at work:

  • Is the rubocop.yml actually in the installed gem? It may be, that it hasn't been included in the install version.
  • Is there a ~/.rubocop.yml with the same content?
  • Is Rubocop up-to-date?

Setup

~/.rubocop.yml:

Metrics/LineLength:
  Max: 100

Rubocop 0.48.1 output

$ bundle exec rubocop -d config/application.rb
For /home/phansch/code/rails_playground: configuration from /home/phansch/code/rails_playground/.rubocop.yml
Inheriting configuration from /home/phansch/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-bug-gem-edf3b83692c7/rubocop.yml
/home/phansch/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-bug-gem-edf3b83692c7/rubocop.yml: Style/LineLength has the wrong namespace - should be Metrics
Default configuration from /home/phansch/.rvm/gems/ruby-2.4.1/gems/rubocop-0.48.1/config/default.yml
Inheriting configuration from /home/phansch/.rvm/gems/ruby-2.4.1/gems/rubocop-0.48.1/config/enabled.yml
Inheriting configuration from /home/phansch/.rvm/gems/ruby-2.4.1/gems/rubocop-0.48.1/config/disabled.yml
AllCops/Exclude configuration from /home/phansch/.rubocop.yml
Inspecting 1 file
Scanning /home/phansch/code/rails_playground/config/application.rb
.

1 file inspected, no offenses detected
Finished in 0.1449760969990166 seconds

Rubocop 0.49.0 output

$ bundle exec rubocop -d config/application.rb
For /home/phansch/code/rails_playground: configuration from /home/phansch/code/rails_playground/.rubocop.yml
Inheriting configuration from /home/phansch/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-bug-gem-faa56588b7ef/rubocop.yml
/home/phansch/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-bug-gem-faa56588b7ef/rubocop.yml: Style/EmptyLines has the wrong namespace - should be Layout
Default configuration from /home/phansch/.rvm/gems/ruby-2.4.1/gems/rubocop-0.49.0/config/default.yml
Inheriting configuration from /home/phansch/.rvm/gems/ruby-2.4.1/gems/rubocop-0.49.0/config/enabled.yml
Inheriting configuration from /home/phansch/.rvm/gems/ruby-2.4.1/gems/rubocop-0.49.0/config/disabled.yml
AllCops/Exclude configuration from /home/phansch/.rubocop.yml
Inspecting 1 file
Scanning /home/phansch/code/rails_playground/config/application.rb
.

1 file inspected, no offenses detected
Finished in 0.09542520699324086 seconds
@phansch
Copy link
Author

phansch commented Jul 17, 2017

I had some time to dig into the config loading code, and it seems to be caused by making the excludes absolute in Config#make_excludes_absolute somewhere.
selection_343

The excludes should be relative to the project that is including the configuration and not relative to the shared gem's path.
Need to figure out why it is working at home an not working at work...

Possible causes: base_dir_for_path_parameters
I guess at home it returns Dir.pwd for some reason

@phansch
Copy link
Author

phansch commented Jul 17, 2017

selection_344
selection_345

@phansch
Copy link
Author

phansch commented Jul 17, 2017

One issue seems to be that the file is starting with .rubocop in the shared gem, if it is called something else, it seems to work. The problem is in File.basename(loaded_path).start_with?('.rubocop')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment