Sonarqube doesn't apply java version 1.4

I would like to analyze part of my project with “sonar.java.source=1.4” (Legacy code on hardware).
The problem is that some issues are systematically raised even though they are not issues in 1.4.

In the example below, issues java:S2129 and java:S1874 are systematically raised.

I’m running “mvn test sonar:sonar -Dsonar.java.source=1.4”
The class:

public class Essai {
public void test()
  {
      Integer toto = new Integer(10);

      Logger.getLogger("toto").log(Level.INFO,toto.toString());
  }
}

pom.xml contains only:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.4</source>
                <target>1.4</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Note: I would like to keep the S2129 and S1874 rules, except for certain methods that are not really deprecated and are often used (like new Integer(int)).

Hi,

I believe it was with Java 7 that we started making rules sensitive to the source version. We never retrofitted this for Java 4 since it was already old at the time.

Your best bet is just to mark these individual issues Accepted or False Positive.

 
HTH,
Ann

Hi thanks for your answer. Is there any way to implement specific rules in our sonarQube, to exclude specific issue patterns?

Hi,

I think that would require a custom rules plugin. It might be easier to upgrade your Java version. :smiley:

 
Ann