FP on rule squid:S4449 in SonarJava 5.4 for Eclipse JDT annotations

eclipse
java

(Frank Benoit) #1

Hi

I use SonarJava 5.4, SonarQube 6.7.1.35068

There is a Assert class with this code:

public static <T> @NonNull T isNotNull( @Nullable T obj ){...}

Those annotations are from org.eclipse.jdt.annotation, and all packages have the @NonNullByDefault in package-info.java

Now an error is reported for this code:

private void scanElements(@Nullable ARPACKAGE pk, String parentId) {
    ARPACKAGE p = isNotNull(pk);

isNotNull() is a static import from that Assert class above.

The error shown: squid:S4449

Annotate the parameter with @javax.annotation.Nullable in method ‘isNotNull’ declaration, or make sure that null can not be passed as argument.

In SonarJava 5.4 there was the fix SONARJAVA-2734, but it seems not to cover this situation.

Thanks for looking at this
Frank


(Michael Gumowski) #3

Hey Frank,

First, welcome on this brand new forum and thank you for your feedback! (and thanks a lot for all the info you provided! :star2:)
I took the liberty to update the formatting of your post in order to take advantage of code formatting.

I have been able to reproduce the issue on my side, and consequently created the following ticket to handle this: SONARJAVA-2790

Cheers,
Michael