Add nullaway
diff --git a/build.gradle b/build.gradle
index f27ab95..671c556 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,6 +6,9 @@
repositories {
jcenter()
google()
+ maven {
+ url "https://plugins.gradle.org/m2/"
+ }
}
dependencies {
classpath 'org.ajoberstar:grgit:1.9.3'
@@ -13,6 +16,7 @@
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlinVersion"
classpath 'org.ajoberstar:grgit:1.9.3'
+ classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.6"
}
}
diff --git a/lottie/build.gradle b/lottie/build.gradle
index 1a76e78..41462a3 100644
--- a/lottie/build.gradle
+++ b/lottie/build.gradle
@@ -1,5 +1,8 @@
+import net.ltgt.gradle.errorprone.CheckSeverity
+
apply from: 'gradle-maven-push.gradle'
apply plugin: 'com.android.library'
+apply plugin: 'net.ltgt.errorprone'
android {
compileSdkVersion 28
@@ -32,8 +35,9 @@
testImplementation "org.robolectric:robolectric:4.0-alpha-3"
// Do not ugprade to 2.0 because it will bring in Kotlin as a transitive dependency.
implementation("com.squareup.okio:okio:1.17.4")
-
-
+ annotationProcessor "com.uber.nullaway:nullaway:0.7.5"
+ errorprone "com.google.errorprone:error_prone_core:2.3.2"
+ errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
}
task javadoc(type: Javadoc) {
@@ -43,6 +47,27 @@
failOnError false
}
+tasks.withType(JavaCompile) {
+ // remove the if condition if you want to run NullAway on test code
+ if (!name.toLowerCase().contains("test")) {
+ options.errorprone {
+ option("NullAway:AnnotatedPackages", "com.airbnb.lottie")
+ // TODO: enable these and fix errors one by one.
+ check("NullAway", CheckSeverity.OFF)
+ check("StringSplitter", CheckSeverity.OFF)
+ check("DefaultCharset", CheckSeverity.OFF)
+ check("HidingField", CheckSeverity.OFF)
+ check("NarrowingCompoundAssignment", CheckSeverity.OFF)
+ check("MissingOverride", CheckSeverity.OFF)
+ check("ReferenceEquality", CheckSeverity.OFF)
+ check("FallThrough", CheckSeverity.OFF)
+ check("FloatingPointLiteralPrecision", CheckSeverity.OFF)
+ check("MissingCasesInEnumSwitch", CheckSeverity.OFF)
+ check("OperatorPrecedence", CheckSeverity.OFF)
+ }
+ }
+}
+
// Re-enable this if releases are uploaded from CI.
//gradle.taskGraph.whenReady { taskGraph ->
// if (taskGraph.allTasks.any { it instanceof Sign }) {
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java b/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java
index 97971ad..3945ee7 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java
@@ -38,7 +38,7 @@
* In-progress tasks will also be held so they can be returned for subsequent requests for the same
* animation prior to the cache being populated.
*/
-@SuppressWarnings({"WeakerAccess", "unused"})
+@SuppressWarnings({"WeakerAccess", "unused", "NullAway"})
public class LottieCompositionFactory {
/**
* Keep a map of cache keys to in-progress tasks and return them for new requests.