[java-inspections] IDEA-346005 Add new inspection: Unnecessary keySet() call

GitOrigin-RevId: d1f1db0ae939017a8550b91cd8742dc222a8db99
This commit is contained in:
Tagir Valeev
2024-09-16 11:48:53 +02:00
committed by intellij-monorepo-bot
parent ecc3d78a3a
commit ac0c57748b
8 changed files with 78 additions and 8 deletions

View File

@@ -0,0 +1,15 @@
// "Fix all 'Redundant 'Collection' operation' problems in file" "true"
import java.util.*;
class Test {
void test(Map<String, String> map) {
if (map.isEmpty()) return;
if (map.isEmpty()) return;
map.remove("oops");
map.values().remove("oops");
if (map.size() > 10) return;
if (map.size() > 10) return;
map.clear();
map.clear();
}
}

View File

@@ -0,0 +1,15 @@
// "Fix all 'Redundant 'Collection' operation' problems in file" "true"
import java.util.*;
class Test {
void test(Map<String, String> map) {
if (map.ke<caret>ySet().isEmpty()) return;
if (map.values().isEmpty()) return;
map.keySet().remove("oops");
map.values().remove("oops");
if (map.keySet().size() > 10) return;
if (map.values().size() > 10) return;
map.keySet().clear();
map.values().clear();
}
}