False positive for missing @deprecated Javadoc tag

  • Operating system: Windows 10
  • SonarLint plugin version: 7.4
  • Programming language you’re coding in: Java
  • Is connected mode used: No

The SonarLint detects a false positive on the item() method for code under here:

@Deprecated(forRemoval = false) @Override
	 * @deprecated This method returns the same item, because it pertains to a single item
	 * @apiNote This method is used for compatibility with {@link SingleItem}
	 * @return this item
	default ItemEntry item() {
		return this;

The full file is available here

Hello Oskar,

Thanks for raising this.

In your code snippet the annotations come before the Javadoc. This is not valid, and even if you try to run the javadoc tool the comment will be ignored.

So this comment is considered a regular comment and not a JavaDoc one, that’s why SonarLint raises an issue about not finding the @deprecated tag.

If you swap the annotations and the comment, then SonarLint will stop reporting (and if you generate the Javadoc the comment will correctly be included).

Hope this helps!

The false positive occurs here too:

* @deprecated This variable boxes result. Use {@link #getDouble()} for better performance
@Deprecated(forRemoval = false) public Double get() {
	return value;

Hello Oskar,

I don’t reproduce the FP on my end with the code you sent. Does it raise the same issue as in your original message (java:S1123 Deprecated elements should have both the annotation and the Javadoc tag) ? I can see another issue raised (java:S1133 Deprecated code should be removed) but this is a true positive.

Don’t hesitate to send us a more complete example, or a pointer to a file. Thanks