SonarLint ignore Java file after analysis errors

Hello,

I am using SonarLint plugin version 4.3.0.3495 with IntelliJ IDEA 2019.3.1 (Ultimate Edition).

For this Java code :

package io.sami.lambda;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;

public class LambdaGenericDemo {
    public static void main(String[] args) {
        LambdaGeneric<Integer> integerLambdaGeneric = new LambdaGeneric<>();

        integerLambdaGeneric.method2(55, 58);

    }
}

class LambdaGeneric<T extends Comparable<T>> {

    static final Logger LOGGER = LogManager.getLogger(LambdaGeneric.class);
    private static final Marker SIMPLE_OUTPUT = MarkerManager.getMarker("SIMPLE");

    private T method(GenericFuncInterface<T> funcInterface, T t1, T t2) {
        return funcInterface.myGenericFunc(t1, t2);
    }

    public void method2(T t1, T t2) {

        GenericFuncInterface<T> tGenericFuncInterface = (ta, tb) -> {
            if (ta.compareTo(tb) < 0) {
                return tb;
            } else {
                return ta;
            }
        };

        GenericFuncInterface<T> tGenericFuncInterface2 = (ta, tb) -> ta.compareTo(tb) < 0 ? tb : ta;

        GenericFuncInterface<T> tGenericFuncInterface3 = (ta, tb) -> switch(ta.compareTo(tb)) {
            case 2, 3, 5 -> tb;
            default -> ta;
        };

        T t = method(tGenericFuncInterface, t1, t2);
        T tt = method(tGenericFuncInterface2, t1, t2);
        T ttt = method(tGenericFuncInterface3, t1, t2);

        LOGGER.info(SIMPLE_OUTPUT, t);
        LOGGER.info(SIMPLE_OUTPUT, tt);
        LOGGER.info(SIMPLE_OUTPUT, ttt);
    }
}

@FunctionalInterface
interface GenericFuncInterface<T> {

    T myGenericFunc(T t1, T t2);
}

I am getting this error inside SonarLint “Log” tab :

Analysing ‘LambdaGenericDemo.java’…
File won’t be refreshed because there were errors during analysis: /home/sami/IdeaProjects/JavaLambda/src/main/java/io/sami/lambda/LambdaGenericDemo.java

After getting this error, SonarLint will ignore this Java file. No more analysis is done.

I am using JDK 13.0.1

Hello, thank you for your feedback.

Switch expressions, as a Java 13 preview feature, are only fully supported by the very latest version of our Java analyzer (6.0.0.20538 as of writing). Previous versions of the analyzer have a type resolution issue with the “final” Java 13 syntax - and indeed you won’t get any issue on source that we can’t correctly analyze :sweat_smile:

Next version of SonarLint for IntelliJ should embed this newer version of the Java analyzer.

As a workaround in the meantime, you can use SonarLint in connected mode, either with SonarCloud or with a SonarQube server that has the latest Java analyzer.