rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

RSPEC-4034 - "Stream" call chains should be simplified when possible

Open yeikel opened this issue 1 year ago • 7 comments


 private static boolean isTypeAllowed(String type) {
        return Set.of("types").stream().filter(type::contains).collect(Collectors.toList()).isEmpty();
    }

 private static boolean isTypeAllowed(String type) {
        return Set.of("types").stream().stream().filter(type::contains).count() == 0
    }


 private static boolean isTypeAllowed(String type) {
        return Set.of("types").stream().noneMatch(type::contains);
    }

More examples : https://rules.sonarsource.com/java/RSPEC-4034

yeikel avatar Mar 14 '23 16:03 yeikel