|
6 | 6 | require "rake" |
7 | 7 |
|
8 | 8 | class ConfigTest < Minitest::Test |
| 9 | + FULL_CONFIG_PATH = "test/fixtures/full_config.yml" |
| 10 | + |
9 | 11 | def test_config_is_unchanged |
10 | 12 | skip if checking_rubocop_version_compatibility? |
11 | 13 |
|
12 | 14 | Rake.application.load_rakefile |
13 | 15 |
|
14 | | - original_config = "test/fixtures/full_config.yml" |
| 16 | + original_config = FULL_CONFIG_PATH |
15 | 17 |
|
16 | 18 | Tempfile.create do |tempfile| |
17 | 19 | Rake::Task["config:dump"].invoke(tempfile.path) |
@@ -70,6 +72,25 @@ def test_config_is_sorted_alphabetically |
70 | 72 | assert_sorted(following_keys, "Keys after AllCops in rubocop.yml must be sorted") |
71 | 73 | end |
72 | 74 |
|
| 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 | + |
73 | 94 | private |
74 | 95 |
|
75 | 96 | def checking_rubocop_version_compatibility? |
|
0 commit comments