From aeeb1ebd38e175a77e7cd64a984037b2c6eab2ee Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Wed, 19 Jun 2019 12:39:41 +0700 Subject: [PATCH] Java8CollectionRemoveIf: testdata fixed (IDEA-214448) GitOrigin-RevId: e9d934fc8d31016744f2302c39651eb6ecfa4de7 --- .../afterForEachRemoveArrayList.java | 4 +--- .../java8CollectionRemoveIf/afterForEachRemoveSimple.java | 6 ++---- .../java8CollectionRemoveIf/afterForEachRemoveToArray.java | 4 +--- .../afterIteratorRemoveInlineNoBrace.java | 4 +--- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveArrayList.java b/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveArrayList.java index d12250aa398f..aa6fc6231359 100644 --- a/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveArrayList.java +++ b/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveArrayList.java @@ -4,8 +4,6 @@ import java.util.*; public class Main { public void removeEmpty(List list) throws Exception { // Copy to avoid CME - for(String item : new ArrayList<>(list)) { - if(item.isEmpty()) list.remove(item); - } + list.removeIf(String::isEmpty); } } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveSimple.java b/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveSimple.java index adaf17610198..534cc9336f48 100644 --- a/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveSimple.java +++ b/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveSimple.java @@ -3,9 +3,7 @@ import java.util.*; public class Main { public void removeEmpty(List list) throws Exception { - for(String item : list) { - // Presumably CopyOnWriteArrayList - if(item.isEmpty()) list.remove(item); - } + // Presumably CopyOnWriteArrayList + list.removeIf(String::isEmpty); } } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveToArray.java b/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveToArray.java index 36fddc4b32fa..aa6fc6231359 100644 --- a/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveToArray.java +++ b/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterForEachRemoveToArray.java @@ -4,8 +4,6 @@ import java.util.*; public class Main { public void removeEmpty(List list) throws Exception { // Copy to avoid CME - for(String item : list.toArray(new String[list.size()])) { - if(item.isEmpty()) list.remove(item); - } + list.removeIf(String::isEmpty); } } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterIteratorRemoveInlineNoBrace.java b/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterIteratorRemoveInlineNoBrace.java index 2c503bf87f1b..d78e5b4e7553 100644 --- a/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterIteratorRemoveInlineNoBrace.java +++ b/java/java-tests/testData/inspection/java8CollectionRemoveIf/afterIteratorRemoveInlineNoBrace.java @@ -4,8 +4,6 @@ import java.util.List; public class Main { public void testIterator(List> data, boolean b) { - for(Iterator> iter = (data.iterator()); iter.hasNext();) - if(iter.next().isEmpty() && /* also check the flag */ b) - iter.remove(); + data.removeIf(strings -> strings.isEmpty() && /* also check the flag */ b); } } \ No newline at end of file