uber / NullAway

A tool to help eliminate NullPointerExceptions (NPEs) in your Java code with low build-time overhead
MIT License
3.63k stars 293 forks source link

JSpecify: Handle @Nullable assignments to @Nonnull arrays #929

Closed armughan11 closed 7 months ago

armughan11 commented 7 months ago

Handles cases in JSpecify mode where a @Nullable element is assigned to an unannotated array. Added relevant unit tests.

Current Behavior

Both are valid assignments.

String [] foo = new String[10];
@Nullable String [] bar = new String [10];
foo[1] = null;
bar[1] = null;

New Behavior

Assignment to foo generates an error since array elements are @Nonnull.

String [] foo = new String[10];
@Nullable String [] bar = new String [10];
foo[1] = null;
bar[1]=null;
codecov[bot] commented 7 months ago

Codecov Report

Attention: Patch coverage is 85.71429% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 87.07%. Comparing base (1c497a7) to head (bdb8f10).

Files Patch % Lines
...away/src/main/java/com/uber/nullaway/NullAway.java 84.61% 0 Missing and 2 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #929 +/- ## ============================================ - Coverage 87.07% 87.07% -0.01% - Complexity 1991 1994 +3 ============================================ Files 77 77 Lines 6430 6444 +14 Branches 1246 1249 +3 ============================================ + Hits 5599 5611 +12 Misses 422 422 - Partials 409 411 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.