Questions about Java :S2175

java:S2175

SonarLint Reported me a bug in the function


    public static <E extends Node> Collection<E> parse(Collection<E> source, Long rootId) {
        Collection<E> roots = getRootNode(source, rootId);
        source.removeAll(roots);
        for (E root: roots) {
            if (source.isEmpty()) break;
            findNodes(source, root);
        }
        return roots ;
    }

source.removeAll(roots);

The collection types of source and roots are the same , Why report to me that this is a bug?

Hello @EalenXie ,

Sorry for this long time before answering you… I can not reproduce the issue on my side, it seems that our analyzer is currently dealing with it correctly. Could you please answer the following questions:

  • Are you still experiencing the issue?
  • What is the signature of getRootNode() method?
  • What is your version of SonarLint?
  • Are you using Connected Mode?
    • if yes, is it to SonarCLoud?
    • if yes, and it’s SonarQube, to what version and what is the embedded version of the Java Analyzer?

Thanks in advance,
Michael