Hi,
We upgraded sonar to 7.9.3 and use SonarJava 6.3.2.22818.
We have a set of rules created and used with sonar. When I compile my project with these settings in pom.xml
<java.plugin.version>6.3.2.22818</java.plugin.version> <!-- minimal version of SonarQube to support.--> <sonar.version>7.9.3</sonar.version>
I get the following error in my project:
11:32:59.299 [main] ERROR org.sonar.java.ast.JavaAstScanner - Unable to parse source file : ‘src/test/files/MemberVarsInitializedCheck.java’
11:32:59.299 [main] ERROR org.sonar.java.ast.JavaAstScanner - Parse error at line 277 column 8: Constructor call must be the first statement in a constructor
The error prone line is:
this(-1, new Object()); // This constructor never initializes the field b
Here is the code in the source file:
public class Test20 {
private String a;
private Object b;
private int c;
// Noncompliant@+1 -- Two noncompliances here; one for each of a and b. @+1 signals that we specify the row below
public Test20(int c, Object o) { // Noncompliant
this.c = c;
}
public Test20(String a) { // Noncompliant
this.a = a;
this(-1, new Object()); // This constructor never initializes the field b
}
public Test20() {
b = new Object();
this("");
}
}
What has changed?
If I change to use this as test case ( unsure if it is correct syntax and will do same as verify)
CheckVerifier newVerifier = JavaCheckVerifier.newVerifier();
newVerifier.withCheck(new MemberVarsInitializedCheck());
instead of this:
JavaCheckVerifier.verify("src/test/files/MemberVarsInitializedCheck.java", new MemberVarsInitializedCheck());
Strange thing is that have the above line for most of my testcases and there it works!
A piece of advice would be greatly appreciated.
//mike