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
Add InternalAffairs/UndefinedConfig
cop.
#9987
Conversation
@@ -1824,7 +1824,6 @@ Lint/MultipleComparison: | |||
Enabled: true | |||
VersionAdded: '0.47' | |||
VersionChanged: '1.1' | |||
AllowMethodComparison: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aabe4d3
to
f27588f
Compare
…keys that are used in cops but not defined in `config/default.yml`.
f27588f
to
295f94d
Compare
Great! This looks like a useful cop. The only thing I'm concern about is that rubocop-minitest may have a false positive. diff --git a/Gemfile b/Gemfile
index ad573e7..6d83faa 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,6 +8,6 @@ gemspec
gem 'bump', require: false
gem 'rake'
-gem 'rubocop', github: 'rubocop/rubocop'
+gem 'rubocop', path: '/path/to/rubocop/rubocop'
gem 'rubocop-performance', '~> 1.11.0'
gem 'yard', '~> 0.9' % bundle exec rake
(snip)
Offenses:
lib/rubocop/cop/minitest/multiple_assertions.rb:58:36: C: InternalAffairs/UndefinedConfig: Max is not defined in the configuration for Minitest/MultipleAssertions in config/default.yml.
Integer(cop_config.fetch('Max', 3))
^^^^^
88 files inspected, 1 offense detected rubocop-minitest can make a workaround to disable this cop if it's not easy to solve. |
@koic should that cop not define |
|
Oh strange, ok I'll look into it thanks! |
@koic I haven't been able to replicate this, I ran the cop on |
@dvandersluis I checked again, but I couldn't reproduce the offense (maybe there was a problem with my local environment...?). Anyway, I'm sorry to take your time. And thank you again for implementing the useful cop! |
Thanks @koic! |
Adds an internal affairs cop to look for cops that use a configuration key without it being defined in
config/default.yml
.I ran into this while adding a cop and accidentally putting a configuration in the wrong element. This internal affairs cop ensures that any configuration key used with
cop_config
in a cop is present in the configuration for that cop.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 runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.