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

--ignore-parent-exclusion does not work if --parallel is used #7790

Closed
dhinus opened this issue Mar 10, 2020 · 1 comment
Closed

--ignore-parent-exclusion does not work if --parallel is used #7790

dhinus opened this issue Mar 10, 2020 · 1 comment

Comments

@dhinus
Copy link

dhinus commented Mar 10, 2020

The switch --ignore-parent-exclusion seems to be ignored if --parallel is also present.


Expected behavior

The following commands should always inspect the same number of files:

rubocop --ignore-parent-exclusion
rubocop --ignore-parent-exclusion --parallel

Actual behavior

Adding --parallel seems to disable the effect of --ignore-parent-exclusion.

Steps to reproduce the problem

.
├── .rubocop.yml
└── subdir
    ├── .rubocop.yml
    └── test.rb

Content of .rubocop.yml:

AllCops:
  Exclude:
    - "subdir/*"

Content of subdir/.rubocop.yml:

AllCops:
  Exclude:
    - "foobar"

This is the output of running Rubocop with different switches, from inside the subdir directory:

  • rubocop: "0 file inspected"
  • rubocop --parallel: "0 file inspected"
  • rubocop --ignore-parent-exclusion: "1 file inspected"
  • rubocop --ignore-parent-exclusion --parallel: "0 files inspected"

NOTE: to be fair, I'm not even sure why I need to use the --ignore-parent-exclusion flag, as I'm not specifying inherit in the config file inside subdir, so I would expect Rubocop to use that file and ignore the config file in the parent directory.

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

$ rubocop -V
0.80.1 (using Parser 2.7.0.2, running on ruby 2.5.1 x86_64-darwin18)
@jonas054
Copy link
Collaborator

NOTE: to be fair, I'm not even sure why I need to use the --ignore-parent-exclusion flag, as I'm not specifying inherit in the config file inside subdir, so I would expect Rubocop to use that file and ignore the config file in the parent directory.

That's by design. If RuboCop, when run from a subdirectory, would inspect files that are excluded when running from the project root, that would be kind of a gotcha. I'm not sure about the exact scenarios when this becomes an issue, but the behavior is not an accident.

@koic koic closed this as completed in 617bee2 Apr 18, 2020
koic added a commit that referenced this issue Apr 18, 2020
…options

[Fix #7790] Set options in ConfigLoader earlier
jonas054 added a commit to jonas054/rubocop that referenced this issue Apr 19, 2020
This fixes another problem that's similar to the one reported in rubocop#7790. The
problem is still that configuration is read and cached when we validate options
vs configuration. By acting on all options first, we make sure that the first
time we read configuration, it's done according to the given options.
Specifically, it's the --force-default-config option that's now being
respected.
bbatsov pushed a commit that referenced this issue Apr 19, 2020
This fixes another problem that's similar to the one reported in #7790. The
problem is still that configuration is read and cached when we validate options
vs configuration. By acting on all options first, we make sure that the first
time we read configuration, it's done according to the given options.
Specifically, it's the --force-default-config option that's now being
respected.
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

No branches or pull requests

2 participants