-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
--only
and ambiguous cop name
#9235
Comments
@dvandersluis can you look into this? |
Sure I'll take a look tomorrow (sorry didn't get a notification about this earlier for some reason). |
So some context:
What's happening here is:
As you can see from the output above, this check happens before the rubocop-rspec configuration is injected (error message is on line 1 but So in this case, the error is due to there being a name conflict between cops in different libraries. I think the best solution here would be to resolve requires earlier so that the registry is full, I'm going to look into how we can achieve that. |
…ly qualify cops added by require. Previously, cop names passed to `--only` or `--except` were qualified immediately, but because the configuration is not yet loaded when `Options.parse` is called, it could not properly resolve cops that are added by an extension or a local `require`. This was generally not a problem because unresolved cops were accepted, but in the case of a cop that shares a name with a default cop, this resulted in raising a warning that the department name was wrong, and in fact loading the wrong cop. Instead, qualifying cop names is now done lazily, so that they are only qualified right before they are needed. This ensures that the full registry is present and external cops can be properly detected.
…ify cops added by require. Previously, cop names passed to `--only` or `--except` were qualified immediately, but because the configuration is not yet loaded when `Options.parse` is called, it could not properly resolve cops that are added by an extension or a local `require`. This was generally not a problem because unresolved cops were accepted, but in the case of a cop that shares a name with a default cop, this resulted in raising a warning that the department name was wrong, and in fact loading the wrong cop. Instead, qualifying cop names is now done lazily, so that they are only qualified right before they are needed. This ensures that the full registry is present and external cops can be properly detected.
FYI @pirj |
Versions: rubocop 1.6.1, rubocop-rspec 2.0.1
This file:
...produces (beside others) this offense:
...but, when I am trying to use
--only RSpec/VariableName
(actually, on a large project, checking each cop's impact):(Notice the warning about namespace)
Shouldn't be this way, I believe :)
The text was updated successfully, but these errors were encountered: