Skip to content

Commit f32f7c2

Browse files
authored
Merge pull request #479 from Shopify/disallow-pending-cops
2 parents a79fa44 + c017c36 commit f32f7c2

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ Style/AndOr:
410410
Style/ArgumentsForwarding:
411411
Enabled: false
412412

413+
Style/ArrayIntersect:
414+
Enabled: false
415+
413416
Style/BisectedAttrAccessor:
414417
Enabled: false
415418

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?

test/fixtures/full_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ Style/ArrayCoercion:
23032303
VersionAdded: '0.88'
23042304
Style/ArrayIntersect:
23052305
Description: Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.
2306-
Enabled: pending
2306+
Enabled: false
23072307
VersionAdded: '1.40'
23082308
Style/ArrayJoin:
23092309
Description: Use Array#join instead of Array#*.

0 commit comments

Comments
 (0)