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 #5979] Introduce cops with special status #7567
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3080a55
[Fix #5979] Introduce cops with special status
34dc15b
fixup! Adjust changelog
pirj feefcdd
fixup! Adjust cop generator
pirj babf585
fixup! Add spec for AllCops/*ByDefault
pirj 39ce911
fixup! Add doc about versioning
pirj be62a57
fixup! Appease RuboCop
pirj 9b36f1f
fixup! Fix alignment
pirj 42dd985
fixup! Add missing parent
pirj File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,9 @@ def configuration_from_file(config_file) | |
else | ||
add_excludes_from_files(config, config_file) | ||
end | ||
merge_with_default(config, config_file) | ||
merge_with_default(config, config_file).tap do |merged_config| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
warn_on_pending_cops(merged_config) | ||
end | ||
end | ||
|
||
def add_excludes_from_files(config, config_file) | ||
|
@@ -114,6 +116,22 @@ def default_configuration | |
end | ||
end | ||
|
||
def warn_on_pending_cops(config) | ||
pending_cops = config.keys.select do |key| | ||
config[key]['Enabled'] == 'pending' | ||
end | ||
|
||
return if pending_cops.none? | ||
|
||
warn Rainbow('The following cops were added to RuboCop, but are not ' \ | ||
'configured. Please set Enabled to either `true` or ' \ | ||
'`false` in your `.rubocop.yml` file:').yellow | ||
|
||
pending_cops.each do |cop| | ||
warn Rainbow(" - #{cop}").yellow | ||
end | ||
end | ||
|
||
# Merges the given configuration with the default one. If | ||
# AllCops:DisabledByDefault is true, it changes the Enabled params so | ||
# that only cops from user configuration are enabled. | ||
|
@@ -231,6 +249,8 @@ def check_cop_config_value(hash, parent = nil) | |
SafeAutoCorrect | ||
AutoCorrect].include?(key) && value.is_a?(String) | ||
|
||
next if key == 'Enabled' && value == 'pending' | ||
|
||
abort( | ||
"Property #{Rainbow(key).yellow} of cop #{Rainbow(parent).yellow}" \ | ||
" is supposed to be a boolean and #{Rainbow(value).yellow} is not." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Versioning | ||
|
||
RuboCop is stable between major versions, both in terms of API and cops. | ||
|
||
New cops introduced between major versions are set to a special pending | ||
status and are not enabled by default. A warning is emitted if such cops | ||
and are not explicitly enabled or disabled in the user configuration. | ||
|
||
On major version updates, pending cops are enabled in bulk. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry about that, but it feels that I might get into a refactoring spiral if I touch ConfigLoader.