False positive for java:S1128 (unused import) when used by Markdown Javadoc

  • What language is this for?
    • Java, relevant for 23
  • Which rule?
    • java:S1128 “Unnecessary imports should be removed”
  • Why do you believe it’s a false-positive/false-negative?
    • The rule description states “Imports for types mentioned in Javadocs are ignored.”, yet types mentioned in a Markdown-style Javadoc comment (cf. JEP 467) are marked as unused.
  • Are you using
    • SonarQube Community Build v25.1.0.102122
    • SonarQube for IDE in IntelliJ 2025.1.1.1, SonarQube version 10.24.0.81420
      • in connected mode with SonarQube Community Build as above
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
    • The following Java code, will raise violations on both import statements despite them being referenced from Javadoc (and two other legitimate violation).
import java.io.InputStream;
import java.io.Serializable;

/// This is a Markdown Javadoc comment.
/// It references [Serializable] and [the transferTo method of InputStream][InputStream#transferTo].
public class Scratch {
  public static void main(String[] args) {
    
  }
}

Hey @loritzm

Can you try SonarQube for IntelliJ 10.25? It should embed a new version of our Java analyzer that supports Java 23. Give it a try and see if you still get the FP.

:warning: Only the latest version of SonarQube Community Build is considered active, so you’ll need to upgrade and see if the situation is still replicable.

Your upgrade path is:

25.1 → 25.6

You may find these resources helpful:

Trying it out in a smaller context (just the IntelliJ plugin now updated to version 10.26.0.81619, unconnected) actually made me discover that SonarQube makes a distinction by Java source level:
When the project is configured for Java 21, it will report the error, when configured for Java 23, it won’t. I guess that’s somewhat consistent with Markdown Javadoc being officially available no earlier than Java 23. The original case therefore didn’t change, but I can see that there’s room for interpretation whether it’s truly a false positive.

In our case, where the main target isn’t the actual javadoc utility, but Javadoc rendering in the IDE (IntelliJ does not seem to make the source level distinction), I’d consider it a minor nuisance that will eventually heal itself when increasing the source level.

Thanks for the response anyway: If nothing else, it made me try harder to get rid of the error. And the next person looking for it can hopefully find these hints.