mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
SimplifyForEachInspection: compilation fix added for non-final var
Adds another alternative to IDEA-177104
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
// "Avoid mutation using Stream API 'count()' operation" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void test(List<String> list) {
|
||||
int count = (int) list.stream().filter(s -> !s.isEmpty()).count();
|
||||
System.out.println(count);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Avoid mutation using Stream API 'max()' operation" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void test(List<String> list) {
|
||||
String longest = list.stream().max(Comparator.comparingInt(String::length)).orElse(null);
|
||||
System.out.println(longest);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Avoid mutation using Stream API 'count()' operation" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void test(List<String> list) {
|
||||
int count = 0;
|
||||
list.forEach(s -> {
|
||||
if(!s.isEmpty()) c<caret>ount++;
|
||||
});
|
||||
System.out.println(count);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Avoid mutation using Stream API 'max()' operation" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
void test(List<String> list) {
|
||||
String longest = null;
|
||||
list.forEach(s -> {
|
||||
if(longest == null || longest.length() < s.length()) longe<caret>st = s;
|
||||
});
|
||||
System.out.println(longest);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user