-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
base: trunk
Are you sure you want to change the base?
[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? |
Yes, those errors only happen in this PR. |
Thank you for pointing this out, I found the reason Until my change, SpotBugs analysis has been run only for classes enclosed in the Files that were not included in My changes have updated the implementation so that SpotBugs analysis is also run for files enclosed in the New bugs found by SpotBugs:
I think this analysis is desired. |
I think a different PR for that makes sense, thank you. |
I merged |
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_level
flag:--//java:nullaway_level=WARN
--//java:nullaway_level=ERROR
NullAway 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@NullMarked
annotation 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_plugin
for NullAway in the Bazel build configuration.selenium-api
andselenium-support
modules by adding it tojava_export
andjava_library
targets.Changes walkthrough 📝
MODULE.bazel
Add NullAway dependency to Maven install
MODULE.bazel
com.uber.nullaway:nullaway:0.11.2
to the list of Mavendependencies.
maven_install.json
Update Maven install with NullAway artifacts
java/maven_install.json
BUILD.bazel
Introduce NullAway Java plugin
java/BUILD.bazel
java_plugin
for NullAway.BUILD.bazel
Configure NullAway for selenium-api module
java/src/org/openqa/selenium/BUILD.bazel
java_export
.javacopts
for NullAway configuration.BUILD.bazel
Configure NullAway for selenium-support module
java/src/org/openqa/selenium/support/BUILD.bazel
java_export
andjava_library
.javacopts
for NullAway configuration.