diff --git a/infer/man/man1/infer-analyze.txt b/infer/man/man1/infer-analyze.txt index da207f89c..bbc23e4d0 100644 --- a/infer/man/man1/infer-analyze.txt +++ b/infer/man/man1/infer-analyze.txt @@ -98,8 +98,9 @@ OPTIONS --no-default-checkers Deactivates: Default checkers: --biabduction, - --fragment-retains-view, --linters, --liveness, --racerd, --siof, - --starvation, --uninit (Conversely: --default-checkers) + --fragment-retains-view, --inefficient-keyset-iterator, --linters, + --liveness, --racerd, --siof, --starvation, --uninit (Conversely: + --default-checkers) --eradicate Activates: the eradicate @Nullable checker for Java annotations @@ -140,10 +141,10 @@ OPTIONS Activates: Enable --immutable-cast and disable all other checkers (Conversely: --no-immutable-cast-only) - --inefficient-keyset-iterator - Activates: Check for inefficient uses of keySet iterator instead - of entrySet iterator. (Conversely: - --no-inefficient-keyset-iterator) + --no-inefficient-keyset-iterator + Deactivates: Check for inefficient uses of keySet iterator that + access both the key and the value. (Conversely: + --inefficient-keyset-iterator) --inefficient-keyset-iterator-only Activates: Enable --inefficient-keyset-iterator and disable all diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 01cfc284b..f59c3a785 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -287,9 +287,9 @@ OPTIONS --no-default-checkers Deactivates: Default checkers: --biabduction, - --fragment-retains-view, --linters, --liveness, --racerd, --siof, - --starvation, --uninit (Conversely: --default-checkers) - See also infer-analyze(1). + --fragment-retains-view, --inefficient-keyset-iterator, --linters, + --liveness, --racerd, --siof, --starvation, --uninit (Conversely: + --default-checkers) See also infer-analyze(1). --no-default-linters Deactivates: Use the default linters for the analysis. @@ -621,10 +621,10 @@ OPTIONS Activates: Enable --immutable-cast and disable all other checkers (Conversely: --no-immutable-cast-only) See also infer-analyze(1). - --inefficient-keyset-iterator - Activates: Check for inefficient uses of keySet iterator instead - of entrySet iterator. (Conversely: - --no-inefficient-keyset-iterator) See also infer-analyze(1). + --no-inefficient-keyset-iterator + Deactivates: Check for inefficient uses of keySet iterator that + access both the key and the value. (Conversely: + --inefficient-keyset-iterator) See also infer-analyze(1). --inefficient-keyset-iterator-only Activates: Enable --inefficient-keyset-iterator and disable all diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index ac0a765c1..616aa5719 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -287,9 +287,9 @@ OPTIONS --no-default-checkers Deactivates: Default checkers: --biabduction, - --fragment-retains-view, --linters, --liveness, --racerd, --siof, - --starvation, --uninit (Conversely: --default-checkers) - See also infer-analyze(1). + --fragment-retains-view, --inefficient-keyset-iterator, --linters, + --liveness, --racerd, --siof, --starvation, --uninit (Conversely: + --default-checkers) See also infer-analyze(1). --no-default-linters Deactivates: Use the default linters for the analysis. @@ -621,10 +621,10 @@ OPTIONS Activates: Enable --immutable-cast and disable all other checkers (Conversely: --no-immutable-cast-only) See also infer-analyze(1). - --inefficient-keyset-iterator - Activates: Check for inefficient uses of keySet iterator instead - of entrySet iterator. (Conversely: - --no-inefficient-keyset-iterator) See also infer-analyze(1). + --no-inefficient-keyset-iterator + Deactivates: Check for inefficient uses of keySet iterator that + access both the key and the value. (Conversely: + --inefficient-keyset-iterator) See also infer-analyze(1). --inefficient-keyset-iterator-only Activates: Enable --inefficient-keyset-iterator and disable all diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index a4345f95a..e7b3c6350 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -655,8 +655,8 @@ and ( annotation_reachability "the detection of object cast from immutable type to mutable type. For instance, it will \ detect cast from ImmutableList to List, ImmutableMap to Map, and ImmutableSet to Set." and inefficient_keyset_iterator = - mk_checker ~long:"inefficient-keyset-iterator" ~default:false - "Check for inefficient uses of keySet iterator instead of entrySet iterator." + mk_checker ~long:"inefficient-keyset-iterator" ~default:true + "Check for inefficient uses of keySet iterator that access both the key and the value." and linters = mk_checker ~long:"linters" ~default:true "syntactic linters" and litho = mk_checker ~long:"litho" "Experimental checkers supporting the Litho framework" and liveness = diff --git a/infer/tests/build_systems/ant/issues.exp b/infer/tests/build_systems/ant/issues.exp index 30e431028..c57c39ec4 100644 --- a/infer/tests/build_systems/ant/issues.exp +++ b/infer/tests/build_systems/ant/issues.exp @@ -92,6 +92,7 @@ codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.Guarded codetoanalyze/java/infer/GuardedByExample.java, codetoanalyze.java.infer.GuardedByExample.writeFBadWrongLock():void, 2, UNSAFE_GUARDED_BY_ACCESS, no_bucket, ERROR, [start of procedure writeFBadWrongLock()] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getAfterClearBad():void, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getAfterClearBad()] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getAfterRemovingTheKeyBad():void, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getAfterRemovingTheKeyBad()] +codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getFromKeySetGood_FP(java.util.HashMap):void, 2, INEFFICIENT_KEYSET_ITERATOR, no_bucket, ERROR, [Accessing a value using a key that was retrieved from a `keySet` iterator. It is more efficient to use an iterator on the `entrySet` of the map, avoiding the extra `HashMap.get(key)` lookup.] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getFromKeySetGood_FP(java.util.HashMap):void, 3, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getFromKeySetGood_FP(...),Taking true branch] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getOneIntegerWithoutCheck():int, 6, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getOneIntegerWithoutCheck()] codetoanalyze/java/infer/HashMapExample.java, codetoanalyze.java.infer.HashMapExample.getTwoIntegersWithOneCheck(java.lang.Integer,java.lang.Integer):void, 8, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure getTwoIntegersWithOneCheck(...),Taking true branch,Taking true branch]