rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

org.openrewrite.staticanalysis.AvoidBoxedBooleanExpressions does not understand @NonNull annotations

Open blipper opened this issue 1 year ago • 2 comments

What is the smallest, simplest way to reproduce the problem?

import lombok.@NonNull

class A {
    void foo(@NonNull Boolean b) {
        if(b) {
        }
}

What did you expect to see?

import lombok.@NonNull

class A {
    void foo(@NonNull Boolean b) {
        if(b) {
        }
}

What did you see instead?

import lombok.@NonNull

class A {
    void foo(@NonNull Boolean b) {
        if(Boolean.TRUE.equals(b)) {
        }
}

What is the full stack trace of any errors you encountered?

stacktrace output here

Are you interested in contributing a fix to OpenRewrite?

blipper avatar Oct 02 '24 18:10 blipper

Thanks @blipper ; indeed seems reasonable not to make any changes to variables annotated as non-nullable. Another case where having nullability included in the type system would help:

  • https://github.com/openrewrite/rewrite/issues/3221

timtebeek avatar Oct 06 '24 11:10 timtebeek

This issue is stale because it has not had any activity for 60 days. Remove question label or comment or this will be closed in two weeks. Issues may be reopened when there is renewed interest.

github-actions[bot] avatar Jul 28 '25 11:07 github-actions[bot]