Skip to content

Commit c017c36

Browse files
committed
Disallow pending cops
While we don't want to blindly enable all new cops, we should take a stance on all cops, so our consumers don't have to. Therefore, no cops should be marked as pending. When a Rubocop bump introduces a new cop, we should triage it and either explicitly enable or disable it. If, for some reason, an update is required during a bad time for triage, the updater should open an triage issue and mark the cop as disabled until it is triaged.
1 parent 446a2de commit c017c36

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test/config_test.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
require "rake"
77

88
class ConfigTest < Minitest::Test
9+
FULL_CONFIG_PATH = "test/fixtures/full_config.yml"
10+
911
def test_config_is_unchanged
1012
skip if checking_rubocop_version_compatibility?
1113

1214
Rake.application.load_rakefile
1315

14-
original_config = "test/fixtures/full_config.yml"
16+
original_config = FULL_CONFIG_PATH
1517

1618
Tempfile.create do |tempfile|
1719
Rake::Task["config:dump"].invoke(tempfile.path)
@@ -70,6 +72,25 @@ def test_config_is_sorted_alphabetically
7072
assert_sorted(following_keys, "Keys after AllCops in rubocop.yml must be sorted")
7173
end
7274

75+
def test_no_cops_are_configured_as_pending
76+
pending_cops = []
77+
78+
load_method = YAML.respond_to?(:unsafe_load_file) ? :unsafe_load_file : :load_file
79+
YAML.public_send(load_method, FULL_CONFIG_PATH).each do |cop_name, cop_config|
80+
pending_cops << cop_name if Hash === cop_config && cop_config["Enabled"] == "pending"
81+
end
82+
83+
assert(pending_cops.empty?, <<~ERROR_MESSAGE.chomp)
84+
Error: The style guide should take a stance on all cops, but following cops are marked as pending:
85+
86+
#{pending_cops.map { " #{_1}:\n Enabled: pending" }.join("\n\n")}
87+
88+
Please update the config to mark all of the these cops as either `Enabled: true` or `Enabled: false`
89+
90+
If this is a bad time to triage, please open an issue, and mark them as `Enabled: false` for now.
91+
ERROR_MESSAGE
92+
end
93+
7394
private
7495

7596
def checking_rubocop_version_compatibility?

0 commit comments

Comments
 (0)