-
-
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
Fix #7231 unknown cop in config file will exit with code 2 #7526
Fix #7231 unknown cop in config file will exit with code 2 #7526
Conversation
Shouldn't this return an error instead? I also think it's bad to reuse the same error code for unknown cop and reported offences. |
yeah that was also confusing me because there is runner_status = execute_runners
if runner_status == STATUS_SUCCESS &&
@config_store.for(Dir.pwd).warnings.any?
raise IncorrectCopNameError.new(@config_store.for(Dir.pwd).warnings.join(', '))
end just let me know what you want to happen in the warning/error case ;) |
I guess there's a difference between an incorrect cop name you've specified manually and something that's in your config that became obsolete, so I probably wouldn't reuse the same exception. Not sure what's the best way to approach this, as I'm not even sure that unknown cops should affect the return status unless this is an explicit error. @rubocop-hq/rubocop-core What do you think about this? |
as rubocop has been bumped to $ bundle exec rake
Running RuboCop...
Error: The `Layout/AlignHash` cop has been renamed to `Layout/HashAlignment`.
(obsolete configuration found in .rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml, please update it)
The `Layout/TrailingBlankLines` cop has been renamed to `Layout/TrailingEmptyLines`.
(obsolete configuration found in .rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml, please update it)
RuboCop failed!
The command "bundle exec rake" exited with 1. An error is logged and rubocops exits with status jethroo-air ~/Workspace/rack-mini-profiler [master]$ bundle exec rubocop
Error: The `Layout/TrailingBlankLines` cop has been renamed to `Layout/TrailingEmptyLines`.
(obsolete configuration found in .rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml, please update it)
jethroo-air ~/Workspace/rack-mini-profiler [master]$ echo $?
2 so maybe this should also happen for unknown cop since the effect on run is the same the specified cop can't be applied. |
Yeah, that's exactly what I had in mind. I think it's fine to just raise an error for unknown cops. |
4674c0f
to
b9a5d2f
Compare
b9a5d2f
to
ff811f0
Compare
@bbatsov as discussed now a |
Thanks! |
This PR addresses the issue raised in #7231. Loading the config file will now memorize the warning for unknown cops and will exit with status
1
if the run would otherwise exit with0
(STATUS_SUCCESS).Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.