nopen icon indicating copy to clipboard operation
nopen copied to clipboard

nopen not respecting disableWarningInGeneratedCode errorprone setting

Open welnanick opened this issue 6 years ago • 2 comments

I am attempting to use nopen with an Android Project, but cannot seem to disable the errors in generated code. nopen is currently flagging the ButterKnife generated view bindings. My app module build.gradle is as follows:

apply plugin: 'com.android.application'
apply plugin: "net.ltgt.errorprone"

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    def keystorePropertiesFile = rootProject.file("keystore.properties")
    def keystoreProperties = new Properties()
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))


    defaultConfig {
        applicationId "com.nickwelna.issuemanagerforgithub"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        buildConfigField "String", "CLIENT_SECRET", keystoreProperties["CLIENT_SECRET"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-beta05'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
    implementation "androidx.navigation:navigation-fragment:2.2.0-beta01"
    implementation "androidx.navigation:navigation-ui:2.2.0-beta01"
    implementation 'com.google.android.material:material:1.1.0-beta01'
    implementation 'com.google.firebase:firebase-core:17.2.0'
    implementation 'com.google.firebase:firebase-auth:19.1.0'
    implementation 'com.google.firebase:firebase-database:19.1.0'
    implementation 'com.jakewharton:butterknife:10.2.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
    implementation 'com.squareup.retrofit2:retrofit:2.6.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.6.2'
    implementation 'com.squareup.retrofit2:converter-moshi:2.6.2'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
    debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
    implementation 'com.google.flogger:flogger:0.4'
    implementation 'com.google.flogger:flogger-system-backend:0.4'
    implementation 'com.squareup.moshi:moshi:1.8.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.2.2'

    compileOnly 'com.jakewharton.nopen:nopen-annotations:1.0.1'
    errorprone "com.google.errorprone:error_prone_core:2.3.3"
    errorprone 'com.jakewharton.nopen:nopen-checker:1.0.1'
    errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
}

android.applicationVariants.all { variant ->
    variant.javaCompileProvider.configure {
        options.errorprone.disableWarningsInGeneratedCode = true
    }
}

apply plugin: 'com.google.gms.google-services'

And my project build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        gradlePluginPortal()
    }
    dependencies {
        classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.1.0'
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Am I missing something?

welnanick avatar Oct 18 '19 00:10 welnanick

Hmm I would have thought this would have been handled automatically by error-prone itself. Each check shouldn't need to do anything here. I will try to reproduce, but I'm on paternity leave for the next 4 weeks so it may take a bit.

A small note: Butter Knife will generate final types if your types are marked as final: https://github.com/JakeWharton/butterknife/blob/41234658847bd7581f8f2afddfd8e3be048ebfcd/butterknife-compiler/src/main/java/butterknife/compiler/BindingSet.java#L108-L110

JakeWharton avatar Oct 18 '19 00:10 JakeWharton

Sorry for the late reply, marking everything as final worked (and honestly is what I wanted to use this plugin to help enforce).

One thing to note, which is probably intended, there were some of the files originally annotated as @Open, but the annotation was dropped in the generated code.

Enjoy your paternity leave! No rush to respond or debug!

welnanick avatar Oct 23 '19 00:10 welnanick