Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantCollectionOperation/beforeContainsRemoveAndAnd.java
Tagir Valeev 4c568edfc9 RedundantCollectionOperation: remove by index and contains before add/remove
IDEA-182694 Inefficient uses of Collection/List.remove
2017-12-25 17:39:36 +07:00

11 lines
282 B
Java

// "Remove the 'contains' check" "true"
import java.util.List;
class Test {
void test(List<String> list, String key) {
if(key !=/*nullcheck*/ null && !key./*check*/isEmpty() && /*and*/ list.co<caret>ntains(/*key*/key//line comment
)) {
list.remove(key);
}
}
}