RedundantCollectionOperation: more tests (IDEA-CR-28150)

This commit is contained in:
Tagir Valeev
2017-12-25 17:50:25 +07:00
parent 4c568edfc9
commit ede06bbf4b
5 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
// "Remove the 'contains' check" "true"
import java.util.*;
class Test {
void test(Set<String> set, String key) {
set.add(key);
}
}

View File

@@ -0,0 +1,10 @@
// "Remove the 'contains' check" "true"
import java.util.*;
class Test {
void test(Set<String> set, String key) {
if(!set.co<caret>ntains(key)) {
set.add(key);
}
}
}

View File

@@ -0,0 +1,10 @@
// "Remove the 'contains' check" "false"
import java.util.*;
class Test {
void test(Set<String> set, String key) {
if(set.co<caret>ntains(key)) {
set.add(key);
}
}
}

View File

@@ -0,0 +1,10 @@
// "Remove the 'contains' check" "false"
import java.util.*;
class Test {
void test(Collection<String> set, String key) {
if(!set.co<caret>ntains(key)) {
set.add(key);
}
}
}

View File

@@ -0,0 +1,10 @@
// "Remove the 'contains' check" "false"
import java.util.List;
class Test {
void test(List<String> list, String key) {
if(!list.co<caret>ntains(/*contains!!!*/key)) {
list.remove(/*remove!!!*/key);
}
}
}