-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding the uber/NullAway error-prone plugin #273
Comments
This issue has been automatically marked as stale because it has not been touched in the last 60 days. Please comment if you'd like to keep it open, otherwise it'll be closed in 7 days time. |
I've just tried NullAway on a couple of internal repos (template-wc and a larger build-related one) - it was incredibly easy to add and seems to have flagged legitimate cases where the type system cannot prove something won't be null. plugins.withId('com.palantir.baseline-error-prone', {
dependencies {
compileOnly 'com.google.code.findbugs:jsr305'
annotationProcessor 'com.uber.nullaway:nullaway'
}
tasks.withType(JavaCompile) {
options.errorprone.errorproneArgs += ['-XepOpt:NullAway:AnnotatedPackages=com.palantir']
}
}) I think a remaining question of how we could roll this out everywhere would be how should that There are plenty of ways you can suppress things too if you get annoyed by this plugin (https://github.com/uber/NullAway/wiki/Suppressing-Warnings) |
This issue has been automatically marked as stale because it has not been touched in the last 60 days. Please comment if you'd like to keep it open, otherwise it'll be closed in 7 days time. |
Closing out because after trying this on the large build repo, it seemed that readability of map accesses was reduced. Each individual repo is still free to add this snippet and I think we'll continue to experiment with this on certain libraries (e.g. tritium). |
Hi @iamdanfox, enabling this nullaway plugin on an internal repo would have found a bug that hit our users, but sadly it wasn't already enabled. I'd like to revisit turning on findbugs by default, or at least making it an easy opt-in as suggested by @carterkozak
From the above thread it looks like this was the only stated issue with enabling nullaway broadly. Could you please expand on what the problem is with map accesses? |
@ash211 here are the illustrative PRs from when I have tried enabling nullaway on large repos:
In both cases, it seemed like there is a very pervasive pattern of having multiple Maps or Sets where there is an invariant that the keysets are exactly equal…. so once you’ve called .get on one, in reality all of the other .get() calls will succeed but static analysis doesn’t know about this invariant... so it forces you to add a bunch of explicit checking. INTERESTINGLY another repo didn't seem to have this same pattern, so I was able to adopt nullaway without too much friction: https://internal-github/foundry/adjudication-service/pull/2766 |
After removing Findbugs from the tritium repo in palantir/tritium#76, it seems like we might actually now be exposed to a few more bugs.
Apparently https://github.com/uber/NullAway catches silly mistakes like:
cc @schlosna
Other things worth investigating:
The text was updated successfully, but these errors were encountered: