I have a class with @UtilityClass
annotation. However, if I won't set the fields as static, sonarqube complains about 0% coverage for these fields. What is interesting, @UtilityClass
annotation automatically adds static fields when it is compiled. So basically .class files are the same for @UtilityClass
with static or without static fields. So why sonarqube shows different results if .class files are the same...?
import lombok.experimental.UtilityClass;
@UtilityClass
public class Test {
public final static String TEST = "test";
}
This class has the same .class file after compilation as this one:
import lombok.experimental.UtilityClass;
@UtilityClass
public class Test {
public final String TEST = "test";
}