|
95 | 95 | end |
96 | 96 | end |
97 | 97 |
|
98 | | - describe "mass_threshold_for" do |
| 98 | + describe "minimum_mass_threshold_for" do |
99 | 99 | it "returns configured mass threshold as integer" do |
100 | 100 | engine_config = described_class.new({ |
101 | 101 | "config" => { |
|
104 | 104 | "mass_threshold" => "13", |
105 | 105 | }, |
106 | 106 | }, |
| 107 | + "checks" => { |
| 108 | + "identical-code" => {}, |
| 109 | + "similar-code" => {}, |
| 110 | + }, |
107 | 111 | }, |
108 | 112 | }) |
109 | 113 |
|
110 | | - expect(engine_config.mass_threshold_for("elixir")).to eq(13) |
| 114 | + expect(engine_config.minimum_mass_threshold_for("elixir")).to eq(13) |
111 | 115 | end |
112 | 116 |
|
113 | 117 | it "returns nil when language is empty" do |
|
119 | 123 | }, |
120 | 124 | }) |
121 | 125 |
|
122 | | - expect(engine_config.mass_threshold_for("ruby")).to be_nil |
| 126 | + expect(engine_config.minimum_mass_threshold_for("ruby")).to be_nil |
123 | 127 | end |
124 | 128 |
|
125 | 129 | it "returns nil when language is empty via array" do |
|
129 | 133 | }, |
130 | 134 | }) |
131 | 135 |
|
132 | | - expect(engine_config.mass_threshold_for("ruby")).to be_nil |
| 136 | + expect(engine_config.minimum_mass_threshold_for("ruby")).to be_nil |
| 137 | + end |
| 138 | + |
| 139 | + it "uses QM threshold when one specified" do |
| 140 | + engine_config = CC::Engine::Analyzers::EngineConfig.new({ |
| 141 | + "config" => { |
| 142 | + "languages" => { |
| 143 | + "ruby" => { "mass_threshold" => 10 }, |
| 144 | + }, |
| 145 | + "checks" => { |
| 146 | + "identical-code" => { "config" => { "threshold" => 5 } }, |
| 147 | + "similar-code" => {}, |
| 148 | + }, |
| 149 | + }, |
| 150 | + }) |
| 151 | + |
| 152 | + expect(engine_config.minimum_mass_threshold_for("ruby")).to eq(5) |
| 153 | + end |
| 154 | + |
| 155 | + it "uses minimum QM threshold when both specified" do |
| 156 | + engine_config = CC::Engine::Analyzers::EngineConfig.new({ |
| 157 | + "config" => { |
| 158 | + "languages" => { |
| 159 | + "ruby" => { "mass_threshold" => 10 }, |
| 160 | + }, |
| 161 | + "checks" => { |
| 162 | + "identical-code" => { "config" => { "threshold" => 5 } }, |
| 163 | + "similar-code" => { "config" => { "threshold" => 8 } }, |
| 164 | + }, |
| 165 | + }, |
| 166 | + }) |
| 167 | + |
| 168 | + expect(engine_config.minimum_mass_threshold_for("ruby")).to eq(5) |
| 169 | + end |
| 170 | + end |
| 171 | + |
| 172 | + describe "#mass_threshold_for" do |
| 173 | + it "gives the QM check treshold when specified" do |
| 174 | + engine_config = CC::Engine::Analyzers::EngineConfig.new({ |
| 175 | + "config" => { |
| 176 | + "languages" => { |
| 177 | + "ruby" => { "mass_threshold" => 10 }, |
| 178 | + }, |
| 179 | + "checks" => { |
| 180 | + "identical-code" => { "config" => { "threshold" => 5 } }, |
| 181 | + "similar-code" => {}, |
| 182 | + }, |
| 183 | + }, |
| 184 | + }) |
| 185 | + |
| 186 | + expect(engine_config.mass_threshold_for("ruby", "identical-code")).to eq(5) |
| 187 | + end |
| 188 | + |
| 189 | + it "gives the legacy language threshold when specified" do |
| 190 | + engine_config = CC::Engine::Analyzers::EngineConfig.new({ |
| 191 | + "config" => { |
| 192 | + "languages" => { |
| 193 | + "ruby" => { "mass_threshold" => 10 }, |
| 194 | + }, |
| 195 | + "checks" => { |
| 196 | + "identical-code" => { "config" => { "threshold" => 5 } }, |
| 197 | + "similar-code" => {}, |
| 198 | + }, |
| 199 | + }, |
| 200 | + }) |
| 201 | + |
| 202 | + expect(engine_config.mass_threshold_for("ruby", "similar-code")).to eq(10) |
| 203 | + end |
| 204 | + |
| 205 | + it "gives nil when no threshold specified" do |
| 206 | + engine_config = CC::Engine::Analyzers::EngineConfig.new({ |
| 207 | + "config" => { |
| 208 | + "languages" => %w[ruby], |
| 209 | + "checks" => { |
| 210 | + "identical-code" => {}, |
| 211 | + "similar-code" => {}, |
| 212 | + }, |
| 213 | + }, |
| 214 | + }) |
| 215 | + |
| 216 | + expect(engine_config.mass_threshold_for("ruby", "identical-code")).to be_nil |
133 | 217 | end |
134 | 218 | end |
135 | 219 |
|
|
0 commit comments