fb-contrib
fb-contrib copied to clipboard
PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS false positive for Java8 .stream()
Collection<String> test(Collection<String> input) {
List<String> aPrefix = input.stream().map(x -> "a" + x).collect(toList());
List<String> bPrefix = input.stream().map(x -> "b" + x).collect(toList());
aPrefix.addAll(bPrefix);
return aPrefix;
}
In the above example I get a PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS for the method stream()Ljava/util/stream/Stream; I don't think this is correct, as streams cannot be reused.
Adding the stream method to https://github.com/mebigfatguy/fb-contrib/blob/d8c62f30273297a702c96ac39bc1d6f878eb2914/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java#L176 should help get rid of this error. But maybe that list is not the best one since it has another purpose, and another one called nonReusables should be created and used.
i believe this was fixed awhile back. please try 7.6.2, and reopen if it's still broken. sorry about not updating.