- versions used (SonarQube Version 6.7.4, SonarAnalyzer, java)
- minimal code sample to reproduce:
Test.java
public static String test(final MyEnum enumeration) {
String result = "";
switch (enumeration) {
case TAI:
result = "toto";
break;
case UTC:
result = "titi";
break;
}
return result;
}
MyEnum.java
public enum MyEnum {
/**
* International Atomic Time.
*
*/
TAI,
/**
* Coordinated Universal Time.
*
*/
UTC;
public String value() {
return name();
}
public static MyEnum fromValue(String v) {
return valueOf(v);
}
}
Sonarqube report that I should add a default case in “Test.java” even if all the constants of the enum “MyEnum” are used.
It seems to be a false positive, isn’t it ?