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

AllCops/Exclude doesn't work as expected #7

Closed
NickLaMuro opened this issue Sep 10, 2020 · 0 comments · Fixed by #12
Closed

AllCops/Exclude doesn't work as expected #7

NickLaMuro opened this issue Sep 10, 2020 · 0 comments · Fixed by #12
Assignees
Labels
bug Something isn't working

Comments

@NickLaMuro
Copy link
Member

NickLaMuro commented Sep 10, 2020

The following configuration:

Exclude:
- spec/manageiq/**/*
- vendor/**/*

Doesn't seem to work as expected, and instead when calculated in rubocop, ends up with the following (the following is some debug output from me working on ManageIQ/miq_bot#500 that I "puts debugged" from the rubocop gem directly):

RuboCop::Config#file_to_exclude? [
  "~/.gem/ruby/2.6.3/gems/manageiq-style-1.1.0/spec/manageiq/**/*",
  "~/.gem/ruby/2.6.3/gems/manageiq-style-1.1.0/vendor/**/*"
]

Don't have an answer on how to fix this properly (besides just removing this and adding it to all the repos manually), but figured it should be made known prior to pushing out something like ManageIQ/miq_bot#506 to all the repos.

@gtanzillo gtanzillo added the bug Something isn't working label Sep 10, 2020
Fryguy added a commit to Fryguy/manageiq-style that referenced this issue Nov 10, 2020
When Excludes are present in an inherited configuration file, Rubocop
will expand_path them.  However, the Excludes in .rubocop_base.yml were
being resolved relative to the gem itself.  Because of this they were
ultimately ignored.

The reason this happens is because Rubocop looks at the filename, and if
it starts with .rubocop, it assumes that is a project-level file, and
will expand relative to the file itself.  Rubocop's own default config
intentionally does _not_ start with .rubocop, as so the default config
is expanded relative to the project. See
https://github.com/rubocop-hq/rubocop/blob/eb3d3583/lib/rubocop/config.rb#L190-L203

The simplest fix for now is to just rename our files to not have
.rubocop at the start of the file name.  We can still keep our
.rubocop_base.yml to avoid renaming it in all of the gems.

Fixes ManageIQ#7
Closes ManageIQ#8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants