RedundantCollectionOperation: warn on if(map.containsKey(x)) map.remove(x)

Review ID: IDEA-CR-28150
This commit is contained in:
Tagir Valeev
2018-01-22 13:39:09 +07:00
parent c95dca14e9
commit 1a40a9f877
4 changed files with 37 additions and 8 deletions
@@ -0,0 +1,9 @@
// "Remove the 'containsKey' check" "true"
import java.util.Map;
class Test {
void test(Map<String, Integer> map, String key) {
/*contains!!!*/
map.remove(/*remove!!!*/key);
}
}
@@ -0,0 +1,10 @@
// "Remove the 'containsKey' check" "true"
import java.util.Map;
class Test {
void test(Map<String, Integer> map, String key) {
if(map.co<caret>ntainsKey(/*contains!!!*/key)) {
map.remove(/*remove!!!*/key);
}
}
}