google / truth

Fluent assertions for Java and Android
https://truth.dev/
Apache License 2.0
2.73k stars 260 forks source link

Annotate the rest of the main package (basically just the Java 8 subjects) for nullness. #1321

Closed copybara-service[bot] closed 4 months ago

copybara-service[bot] commented 4 months ago

Annotate the rest of the main package (basically just the Java 8 subjects) for nullness.

And move the @NullMarked annotation from individual classes up to the package.

Motivation:

(In principle, I should now add @NullUnmarked to all of Truth's test classes, since they haven't been annotated. But doing so would have little to no effect in practice unless maybe IntelliJ recognizes @NullUnmarked (probably not now?) or we improve our nullness offerings in Error Prone. I'm planning to not bother, but let me know if I'm being overly lazy.)

Note that this CL applies @Nullable to some assertion methods' parameters even though those assertions would always fail if the callers passed null. This follows a principle that we'd applied (albeit incompletely) in cl/516515683, which showed that such changes avoided producing build errors in existing, working code. The principle is the same as that discussed for EqualsTester in cl/578260904.

Fixes https://github.com/google/truth/issues/1320

RELNOTES=Annotated the rest of the main package for nullness, and moved the @NullMarked annotation from individual classes up to the package to avoid a warning under --release 8.