[eradicate] add support for the Android support v4 @NonNull annotation

Summary:
The @NonNull annotation, with camel case, can now be used to inform Eradicate that some fields that are not initialized by the constructor can be initialized by other means, e.g. via dependency injection.
master
jrm 9 years ago
parent a7da6066e5
commit c0446276a1

@ -0,0 +1,7 @@
prebuilt_jar(
name = 'android-support-v4',
binary_jar = 'android-support-v4.jar',
visibility = [
'PUBLIC',
],
)

@ -100,6 +100,7 @@ let inject = "Inject"
let mutable_ = "Mutable"
let nullable = "Nullable"
let nonnull = "Nonnull"
let camel_nonnull = "NonNull"
let notnull = "NotNull"
let present = "Present"
let strict = "com.facebook.infer.annotation.Strict"
@ -112,7 +113,9 @@ let ia_is_present ia =
ia_ends_with ia present
let ia_is_nonnull ia =
ia_ends_with ia nonnull || ia_ends_with ia notnull
ia_ends_with ia nonnull
|| ia_ends_with ia notnull
|| ia_ends_with ia camel_nonnull
let ia_is_initializer ia =
ia_contains ia initializer_

@ -5,6 +5,7 @@ dependencies = [
'//infer/lib/java/android:android',
'//dependencies/java/jsr-305:jsr-305',
'//dependencies/java/jsr-330:jsr-330',
'//dependencies/java/android/support/v4:android-support-v4',
]
java_library(

@ -9,6 +9,8 @@
package codetoanalyze.java.eradicate;
import android.support.annotation.NonNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
@ -23,6 +25,8 @@ public class FieldNotInitialized {
@Inject String d; // Means: assume it will be initialized via dependency injection
@NonNull String e;
// Eradicate should only report one initialization error
FieldNotInitialized() {}

Loading…
Cancel
Save