mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 14:25:04 +07:00
for loop -> forEach call chain inspection
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with forEach" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
foo.forEach(this::bar);
|
||||
}
|
||||
|
||||
void bar(String s){}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with forEach" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
foo.stream().filter(s -> s != null).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with forEach" "false"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
for (String s : fo<caret>o) {
|
||||
if (s == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with forEach" "false"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
for (String s : fo<caret>o) {
|
||||
if (s == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with forEach" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
for (String s : fo<caret>o) {
|
||||
bar(s)
|
||||
}
|
||||
}
|
||||
|
||||
void bar(String s){}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with forEach" "false"
|
||||
class Sample {
|
||||
void foo(It it){
|
||||
for (String s : i<caret>t) {
|
||||
if (s == null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class It implements Iterable<String> {}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with forEach" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
for (String s : fo<caret>o) {
|
||||
if (s != null) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with forEach" "false"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
String foo(){
|
||||
boolean b = true;
|
||||
for (String s : f<caret>oo) {
|
||||
if (s == null) {
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with forEach" "false"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
String foo(){
|
||||
for (String s : fo<caret>o) {
|
||||
if (s == null) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user