squid:UselessImportCheck false positive with lombok.var

(Philippe Couton) #1

Strangely, the following Java code :

import lombok.val;
import lombok.var;

class Foo {
    public void test() {
        var foo1 = "hello, ";
        val foo2 = 5;

        System.out.println(foo1 + foo2);

triggers the squid:UselessImportCheck rule for import lombok.var, but not for import lombok.val. Both imports are used, so there should be no detected violation.

Please note that this is Java 7 code, so var is not a keyword in this context. To enforce this, the property sonar.java.source=1.7 has been set in the properties file of the analyzer.

Versions used : SonarQube 6.7.3, scanner, Java analyzer 5.11)