Skip to content

Commit

Permalink
feat: turn on lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mchuangatmp committed Sep 8, 2021
1 parent 6bd755a commit 9c98535
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 37 deletions.
13 changes: 6 additions & 7 deletions android-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ apply plugin: 'com.android.library'
apply from: '../scripts/maven.gradle'
apply plugin: 'kotlin-android'

def javaVersion = JavaVersion.VERSION_1_6

android {
compileSdkVersion 30
buildToolsVersion '30.0.2'
buildToolsVersion '30.0.3'
packagingOptions {
exclude 'META-INF/LICENSE'
}
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

String url = '\"\"'
Expand Down Expand Up @@ -86,7 +84,7 @@ android {
}
}
lintOptions {
abortOnError false
abortOnError true
enable 'UnknownNullness'
lintConfig file('lint.xml')
}
Expand Down Expand Up @@ -115,6 +113,7 @@ task coreSdkJavadocs(type: Javadoc) {
}

dependencies {
//noinspection GradleCompatible
compileOnly 'com.google.firebase:firebase-messaging:[10.2.1, )'

compileOnly 'com.android.installreferrer:installreferrer:[1.0, )'
Expand All @@ -129,7 +128,7 @@ dependencies {
//the junit tests seem to explicitly need this dependency while
//working in Android studio, but from the command line it's not necessary
testImplementation project(':android-core')
testImplementation 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.2'
testImplementation files('libs/java-json.jar')
testImplementation 'org.powermock:powermock-module-junit4:2.0.7'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class MPServiceUtil {
public static final String NOTIFICATION_CHANNEL = "com.mparticle.default";
public static final String INTERNAL_NOTIFICATION_TAP = "com.mparticle.push.notification_tapped";
private static PowerManager.WakeLock sWakeLock;
private static final String TAG = Constants.LOG_TAG;
private static final String TAG = Constants.LOG_TAG + ":wakeLock";
private static final Object LOCK = MPService.class;

private Context mContext;
Expand Down
19 changes: 12 additions & 7 deletions android-kit-base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,25 @@ ext {
apply plugin: 'com.android.library'
apply from: '../scripts/maven.gradle'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'


android {
compileSdkVersion 30
buildToolsVersion '30.0.2'
buildToolsVersion '30.0.3'

testBuildType 'debug'

defaultConfig {
minSdkVersion 14
targetSdkVersion 30

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

buildTypes {

debug {
minifyEnabled false
buildConfigField 'Boolean', 'MP_DEBUG', 'true'
}

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand All @@ -41,6 +37,15 @@ android {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
baseline file("lint-baseline.xml")
}
}

task kitSdkJavadocs(type: Javadoc) {
Expand All @@ -60,7 +65,7 @@ task kitSdkJavadocs(type: Javadoc) {
dependencies {
implementation project(':android-core')

testImplementation 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.2'
testImplementation files('libs/java-json.jar')
testImplementation 'org.powermock:powermock-module-junit4:2.0.7'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.2'
Expand All @@ -69,5 +74,5 @@ dependencies {
testImplementation project(':testutils')

androidTestImplementation project(':testutils')
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.annotation:annotation:1.2.0'
}
11 changes: 11 additions & 0 deletions android-kit-base/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="5" by="lint 4.0.1" client="gradle" variant="all" version="4.0.1">

<issue
id="LintError"
message="Unexpected failure during lint analysis (this is a bug in lint or one of the libraries it depends on)&#xA;&#xA;Message: com/mparticle/tooling/Logger&#xA;&#xA;The crash seems to involve the detector `com.mparticle.lints.basedetectors.BaseDetector`.&#xA;You can try disabling it with something like this:&#xA;    android {&#xA;        lintOptions {&#xA;            disable &#xA;        }&#xA;    }&#xA;&#xA;Stack: `NoClassDefFoundError:BaseDetector.beforeCheckEachProject(BaseDetector.kt:29)←LintDriver.checkProject(LintDriver.kt:897)←LintDriver.analyze(LintDriver.kt:426)←LintCliClient.run(LintCliClient.kt:252)←LintGradleClient.run(LintGradleClient.java:299)←LintGradleExecution.runLint(LintGradleExecution.java:307)←LintGradleExecution.lintAllVariants(LintGradleExecution.java:432)←LintGradleExecution.analyze(LintGradleExecution.java:101)`&#xA;&#xA;You can set environment variable `LINT_PRINT_STACKTRACE=true` to dump a full stacktrace to stdout.">
<location
file="android-kit-base"/>
</issue>

</issues>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.mparticle.commerce.CommerceEvent
import com.mparticle.identity.MParticleIdentityClientImpl
import com.mparticle.internal.Logger
import org.json.JSONArray
import kotlin.collections.forEach as kForEach

import org.json.JSONObject;

Expand Down Expand Up @@ -96,7 +97,7 @@ Data Plan parsed for Kit Filtering:
}
if (event is CommerceEvent) {
val productActionDatapoint = dataPoints["$dataPointKey.$PRODUCT_ACTION_PRODUCTS"]
event.products?.forEach { product ->
event.products?.kForEach { product ->
product?.customAttributes?.apply {
val filteredAttributes = filterKeys {
productActionDatapoint?.contains(it) ?: true
Expand All @@ -107,8 +108,8 @@ Data Plan parsed for Kit Filtering:
}
val productImpressionDatapoint = dataPoints["$dataPointKey.$PRODUCT_IMPRESSION_PRODUCTS"]
if (event.impressions?.size ?: 0 > 0) {
event.impressions?.forEach {
it.products.forEach { product ->
event.impressions?.kForEach {
it.products.kForEach { product ->
product?.customAttributes?.apply {
val filteredAttributes = filterKeys {
productImpressionDatapoint?.contains(it) ?: true
Expand Down Expand Up @@ -222,14 +223,14 @@ Data Plan parsed for Kit Filtering:
?.optJSONArray("data_points")
?.toList()
?.filterIsInstance<JSONObject>()
?.forEach {
?.kForEach {
val match = it.getJSONObject("match")
val key = generateDatapointKey(match)
if (key != null) {
val properties = getAllowedKeys(key, it)
points.put(key.toString(), properties)
val productKeys = key.getProductDataPoints()
productKeys?.forEach { productKey ->
productKeys?.kForEach { productKey ->
points.put(productKey.toString(), getAllowedKeys(productKey, it))
}
}
Expand Down Expand Up @@ -407,7 +408,7 @@ Data Plan parsed for Kit Filtering:

fun <T> Iterator<T>.toHashSet(): HashSet<T> {
val set = HashSet<T>()
this.forEach { set.add(it) }
this.kForEach { set.add(it) }
return set
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.4.10'
ext.kotlin_version = '1.5.30'

repositories {
jcenter()
Expand Down
16 changes: 8 additions & 8 deletions kit-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ ext {
apply from: '../scripts/maven.gradle'

dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:4.0.1'
implementation gradleApi()
implementation localGroovy()
implementation 'com.android.tools.build:gradle:4.0.1'
}

compileGroovy {
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

dependencies {
testCompile 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.2'
}

task pluginJavadocsJar(type: Jar, dependsOn: groovydoc) {
classifier = 'javadoc'
archiveClassifier.set("javadoc")
from groovydoc.destinationDir
}

task pluginSourcesJar(type: Jar) {
classifier = 'sources'
archiveClassifier.set("sources")
from sourceSets.main.allJava
}

Expand Down
6 changes: 3 additions & 3 deletions tooling/android-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
implementation gradleApi()
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation files('libs/java-json.jar')
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
testImplementation project(':tooling:common')
}

Expand All @@ -39,12 +39,12 @@ jar {
}

task pluginJavadocsJar(type: Jar, dependsOn: groovydoc) {
classifier = 'javadoc'
archiveClassifier.set("javadoc")
from groovydoc.destinationDir
}

task pluginSourcesJar(type: Jar) {
classifier = 'sources'
archiveClassifier.set("sources")
from sourceSets.main.allJava
}

Expand Down
7 changes: 6 additions & 1 deletion tooling/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ repositories {

dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile files('libs/java-json.jar')
api files('libs/java-json.jar')
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
8 changes: 5 additions & 3 deletions tooling/custom-lint-rules/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import proguard.gradle.ProGuardTask

apply plugin: 'java'
apply plugin: 'kotlin'

Expand Down Expand Up @@ -38,8 +40,8 @@ dependencies {
compile project(':tooling:common')
compileOnly 'com.android.tools.lint:lint-api:26.5.3'
compileOnly 'com.android.tools.lint:lint-checks:26.5.3'
compileOnly 'org.codehaus.groovy:groovy-all:2.4.15'
testImplementation 'junit:junit:4.12'
compileOnly 'org.codehaus.groovy:groovy-all:3.0.7'
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.android.tools.lint:lint:26.5.3'
testImplementation 'com.android.tools.lint:lint-tests:26.5.3'
testImplementation 'com.android.tools:testutils:26.5.3'
Expand Down Expand Up @@ -75,7 +77,7 @@ task zipSources(type: Jar) {
outputs.upToDateWhen { false }
}

task proguardCore(type: proguard.gradle.ProGuardTask) {
task proguardCore(type: ProGuardTask) {
configuration 'mparticle-core-proguard.pro'
injars 'libs/mparticle.jar'
outjars 'libs/mparticle-min.jar'
Expand Down

0 comments on commit 9c98535

Please sign in to comment.