-
-
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 |
Apologies for the delay in responding, @mk868. I will run the CI again and merge it if everything is working well. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## trunk #14421 +/- ##
==========================================
+ Coverage 58.59% 58.61% +0.01%
==========================================
Files 94 94
Lines 5995 5997 +2
Branches 259 259
==========================================
+ Hits 3513 3515 +2
Misses 2223 2223
Partials 259 259 ☔ View full report in Codecov by Sentry. |
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?
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.