jakewharton / nopen Goto Github PK
View Code? Open in Web Editor NEWAn error-prone checker which requires that classes be final, abstract or annotated with @ Open.
License: Apache License 2.0
An error-prone checker which requires that classes be final, abstract or annotated with @ Open.
License: Apache License 2.0
Open to a PR with a lint analogue of this? Benefit being that it could show up in the IDE as they're typing
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?
Probably a check which checks if the class is not marked with @Open
or abstract should not have any subclasses.
On a related note, it will be a great thing to have FinalByDefault (similar to NonNullByDefault) baked in the type system via EP check or checker framework.
hey @JakeWharton first of all thanks for the great work.
I'd love to see nopen also checking non-final methods when they should be.
I believe it makes sense to be within this lib, but this is you to say.
The idea is pretty much similar to @OPEN, but for methods.
A method should be final (when possible) or annotated.
I've made a Draft PR (more like a POC), #8 and happy to chat about.
If you are willing to bring this in and accept a PR, I'd gladly work on it.
Thanks a lot :)
We shouldn't enforce the use of our annotation artifact
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.