[infer][eradicate] example of error messages involving the temporary variables used to translate logical operations and conditional assignment

Reviewed By: ezgicicek

Differential Revision: D13516477

fbshipit-source-id: 37096f273
master
Nikos Gorogiannis 6 years ago committed by Facebook Github Bot
parent de3c7bac45
commit 24bd229ada

@ -293,4 +293,19 @@ public class NullMethodCall {
String callingSeverSideNullableGetter(ServerSideDeserializer deserializer) {
return deserializer.nullableGetter().toString();
}
interface AnotherI {
void withBooleanParameter(boolean test);
void withObjectParameter(Object object);
}
void withConjuction(@Nullable AnotherI i, boolean test1, boolean test2) {
i.withBooleanParameter(test1 && test2);
}
void withConditionalAssignemnt(
@Nullable AnotherI i, boolean test, Object object1, Object object2) {
i.withObjectParameter(test ? object1 : object2);
}
}

@ -99,6 +99,16 @@ public class ParameterNotNullable {
void indirectSignatureLookupOk(SomeClass c) {
c.acceptsNullableParameter(null);
}
void doesNotAcceptNullableFirstParameter(Object object, boolean test) {}
void callWithNullableFirstParameter(boolean t1, boolean t2) {
doesNotAcceptNullableFirstParameter(null, t1 && t2);
}
void callWithConditionalAssignment(Object object, boolean test) {
doesNotAcceptNullableFirstParameter(test ? object : null, test);
}
}
interface SomeInterface {

@ -63,9 +63,13 @@ codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.N
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testMapRemoveBad(java.util.Map,java.util.HashMap,java.util.concurrent.ConcurrentHashMap):void, 4, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `chm.remove(...)` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to remove(...) modelled in modelTables.ml at line 266)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testSystemGetPropertyReturn():void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `s` in the call to `length()` is nullable and is not locally checked for null. (Origin: call to getProperty(...) modelled in modelTables.ml at line 232)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testSystemGetenvBad():int, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `envValue` in the call to `length()` is nullable and is not locally checked for null. (Origin: call to getenv(...) modelled in modelTables.ml at line 237)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.withConditionalAssignemnt(codetoanalyze.java.eradicate.NullMethodCall$AnotherI,boolean,java.lang.Object,java.lang.Object):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [The value of `$T1_11` in the call to `withObjectParameter(...)` is nullable and is not locally checked for null. (Origin: method parameter i)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.withConjuction(codetoanalyze.java.eradicate.NullMethodCall$AnotherI,boolean,boolean):void, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [The value of `$T1_14` in the call to `withBooleanParameter(...)` is nullable and is not locally checked for null. (Origin: method parameter i)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable$ConstructorCall.<init>(codetoanalyze.java.eradicate.ParameterNotNullable,int), 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable$ConstructorCall(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 95)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.callNull():void, 2, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.test(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: null constant at line 33)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.callNullable(java.lang.String):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`ParameterNotNullable.test(...)` needs a non-null value in parameter 1 but argument `s` can be null. (Origin: method parameter s)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.callWithConditionalAssignment(java.lang.Object,boolean):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.doesNotAcceptNullableFirstParameter(...)` needs a non-null value in parameter 1 but argument `$T0_10` can be null. (Origin: null constant at line 110)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.callWithNullableFirstParameter(boolean,boolean):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`ParameterNotNullable.doesNotAcceptNullableFirstParameter(...)` needs a non-null value in parameter 1 but argument `$T1_15` can be null. (Origin: null constant at line 106)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testClassGetResourceArgument(java.lang.Class):java.net.URL, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`Class.getResource(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 75)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testSystemGetPropertyArgument():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`System.getProperty(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 65)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, codetoanalyze.java.eradicate.ParameterNotNullable.testSystemGetenvBad():java.lang.String, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [origin,`System.getenv(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 71)]

Loading…
Cancel
Save