We don't actually support switch statements yet

This commit is contained in:
Gwilym Kuiper
2020-02-18 17:07:22 +00:00
parent 9d0fb82d6f
commit acfbb132d1

View File

@ -97,48 +97,7 @@ public class Complicated {
<priority>3</priority>
<example>
<![CDATA[
public class ExampleClass {
// Cognitive complexity of 1, cyclomatic complexity of 5
public String SimpleMethod(int number) {
switch on number { // +1
when 1 {
return "one";
}
when 2 {
return "two";
}
when 3 {
return "three";
}
when 4 {
return "a few";
}
when else {
return "lots";
}
}
}
// Cognitive complexity of 9, cyclomatic complexity of 5
public Integer ComplicatedMethod(Integer n) {
Integer total = 0;
for (Integer candidatePrime = 0; candidatePrime < n; i++) { // +1
Boolean isPrime = true;
for (Integer i = 2; i * i < candidatePrime; j++) { // +2
if (candidatePrime % i == 0) { // +3
isPrime = false;
break; // +1
}
}
if (isPrime) { // +2
total += candidatePrime;
}
}
return total;
}
}
// TODO
]]>
</example>
</rule>