rewrite-static-analysis
rewrite-static-analysis copied to clipboard
RSPEC-4034 - "Stream" call chains should be simplified when possible
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