-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[java] NullAway checks added #14421
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
[java] NullAway checks added #14421
Conversation
PR Reviewer Guide 🔍(Review updated until commit a1bc007)
|
PR Code Suggestions ✨
|
|
Why not |
|
@joerg1985 I have such steps in my mind:
What do you think? |
|
What is the ideal way to proceed? Should we have the build fail if this check fails, or should the CI pipeline fail? I tend to prefer the latter. What do you think? |
|
Agree, So, I'll modify PR:
Does it sound good? |
selenium-api and selenium-support|
/describe |
|
Preparing PR description... |
|
/review |
|
Persistent review updated to latest commit a1bc007 |
|
Hi @joerg1985, @diemol |
|
Branch rebased |
|
Hello, I just pushed two commits, with changes:
I'm still not sure if the changes related to NullAway in the GitHub pipeline that I proposed fit the Selenium workflow. |
|
Is there any chance to merge this? |
|
Are the spotbugs failures coming from the checks you added? |
|
To be honest, these SpotBugs errors are confusing to me because there is no clear error message Could you re-run GitHub Workflow to see if the problem is repeatable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mk868 it looks like the new check is already making CI fail. That is good. Do you think you can fix the errors and then we can merge, please?
|
@diemol Currently we have ~80 NullAway errors only for the I can fix these errors progressively in separate PRs (as I have done so far, 2-3 changed files per PR), and then we can merge the |
|
That sounds good, thank you. |
User description
Description
In this PR I'm adding NullAway nullness analyzer to the project. By default NullAway plugin is disabled, to enable them set
//java:nullaway_levelflag:--//java:nullaway_level=WARN--//java:nullaway_level=ERRORNullAway Configuration details:
-Xep:NullAway:WARN- report problems as warnings-Xep:NullAway:ERROR- report problems as errors - stop compilation when an error occurs-XepOpt:NullAway:AnnotatedPackages=org.openqa.selenium- analyze this package (including subpackages)-XepOpt:NullAway:JSpecifyMode=true- enable support for annotations on generic typesNOTE: NullAway has a special behavior, all classes located under AnnotatedPackages are treated as annotated with
@NullMarked- source. Anyway, We need to mark these classes with@NullMarkedannotation manually to remain compliant with JSpecify specification.As suggested, I also added null checking as part of the GitHub workflow.
Motivation and Context
The JSpecify nullness annotations will give developers better exposure to potential problems with their code to avoid NullPointerExceptions.
Related issue: #14291
To verify potential problems with the Selenium source code, we can use nullness analyzers that report code issues based on JSpecify annotations.
One of plugins that is easy to configure with Bazel is NullAway, potential alternatives described here.
Context: #14372 (comment)
Types of changes
Checklist
PR Type
enhancement, configuration changes
Description
java_pluginfor NullAway in the Bazel build configuration.selenium-apiandselenium-supportmodules by adding it tojava_exportandjava_librarytargets.Changes walkthrough 📝
MODULE.bazel
Add NullAway dependency to Maven installMODULE.bazel
com.uber.nullaway:nullaway:0.11.2to the list of Mavendependencies.
maven_install.json
Update Maven install with NullAway artifactsjava/maven_install.json
BUILD.bazel
Introduce NullAway Java pluginjava/BUILD.bazel
java_pluginfor NullAway.BUILD.bazel
Configure NullAway for selenium-api modulejava/src/org/openqa/selenium/BUILD.bazel
java_export.javacoptsfor NullAway configuration.BUILD.bazel
Configure NullAway for selenium-support modulejava/src/org/openqa/selenium/support/BUILD.bazel
java_exportandjava_library.javacoptsfor NullAway configuration.