[eradicate] match the different re-definitions of Preconditions.checkState

Reviewed By: mbouaziz

Differential Revision: D13966540

fbshipit-source-id: 3cdbb3fbc
master
Jeremy Dubreil 6 years ago committed by Facebook Github Bot
parent 50b1533921
commit d08cabe7ed

@ -68,10 +68,14 @@ let get_check_not_null_parameter proc_name =
(** Check if the procedure is one of the known Preconditions.checkState. *)
let is_check_state proc_name = table_has_procedure check_state_table proc_name
let is_check_state proc_name =
table_has_procedure check_state_table proc_name || match_method_name proc_name "checkState"
(** Check if the procedure is one of the known Preconditions.checkArgument. *)
let is_check_argument proc_name = table_has_procedure check_argument_table proc_name
let is_check_argument proc_name =
table_has_procedure check_argument_table proc_name || match_method_name proc_name "checkArgument"
(** Check if the procedure does not return. *)
let is_noreturn proc_name = table_has_procedure noreturn_table proc_name

@ -11,4 +11,8 @@ import javax.annotation.Nullable;
public class MyPreconditions {
public static native <T> T checkNotNull(@Nullable T t);
public static native void checkState(boolean expression);
public static native void checkArgument(boolean expression);
}

@ -287,6 +287,16 @@ public class NullMethodCall {
return nullableField.toString();
}
String customPreconditionsCheckStateOkay() {
MyPreconditions.checkState(nullableField != null);
return nullableField.toString();
}
String customPreconditionsCheckArgumentOkay(@Nullable Object arg) {
MyPreconditions.checkState(arg != null);
return arg.toString();
}
void nullMethodCallWithAlarmManager(AlarmManager manager, @Nullable PendingIntent intent) {
manager.cancel(intent);
}

@ -51,7 +51,7 @@ codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.N
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.FP_propagatesNonNullAfterComparisonFieldOkay(java.lang.Object):void, 2, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [origin,The value of `NullMethodCall.nullableField` in the call to `toString()` is nullable and is not locally checked for null. (Origin: field NullMethodCall.nullableField at line 273)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.FP_propagatesNonNullAfterComparisonParameterOkay(java.lang.Object,java.lang.Object):void, 3, ERADICATE_NULL_METHOD_CALL, no_bucket, WARNING, [The value of `nullableParameter` in the call to `toString()` is nullable and is not locally checked for null. (Origin: method parameter nullableParameter)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.callOnNull():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: null constant at line 23)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.callingSeverSideNullableGetter(codetoanalyze.java.eradicate.ServerSideDeserializer):java.lang.String, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, ERROR, [origin,The value of `deserializer.nullableGetter()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to nullableGetter() at line 295)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.callingSeverSideNullableGetter(codetoanalyze.java.eradicate.ServerSideDeserializer):java.lang.String, 1, ERADICATE_NULL_METHOD_CALL, no_bucket, ERROR, [origin,The value of `deserializer.nullableGetter()` in the call to `toString()` is nullable and is not locally checked for null. (Origin: call to nullableGetter() at line 305)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.nullMethodCallWithAlarmManager(android.app.AlarmManager,android.app.PendingIntent):void, 1, ERADICATE_PARAMETER_NOT_NULLABLE, no_bucket, WARNING, [`AlarmManager.cancel(...)` needs a non-null value in parameter 1 but argument `intent` can be null. (Origin: method parameter intent)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testExceptionPerInstruction(int):void, 6, 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: null constant at line 179)]
codetoanalyze/java/eradicate/NullMethodCall.java, codetoanalyze.java.eradicate.NullMethodCall.testFieldAssignmentIfThenElse(java.lang.String):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: null constant at line 170)]

Loading…
Cancel
Save