We don't actually support switch statements yet
This commit is contained in:
@ -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>
|
||||
|
Reference in New Issue
Block a user