Affects Sonarqube Version:
Sonarqube version: 8.1.0.31237
sonar-scanner version: 4.2.0.1873-windows
Rule:
S3010: Static fields should not be updated in constructors
Description:
Unable to detect static variables updated in a special case: foo++
.
This rule is implemented in java-checks-6.2.0.21135-sources.jar!\org\sonar\java\checks\StaticFieldUpdateInConstructorCheck.java,
This rule first finds the static variable, and then finds the assignment by public void visitAssignmentExpression(AssignmentExpressionTree tree) {
, maybe the ++ operation is not in the assignment statement
Code Sample demonstrating the issue:
public class Marciano {
public String nombre;
public static int CONT = 0;
public Marciano(String n){
nombre = n;
CONT++;
}
}
Expected outcome:
false-negative
Running Sonarqube through:
command line