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?