SonarLint for Eclipse report wrong warning for `This block of commented-out lines of code should be removed.`

Hi,

I see a wrong warning about comments on real code.

  • This block of commented-out lines of code should be removed.

Example:

public class LocalSelectionTransfer extends ByteArrayTransfer {

// First attempt to create a UUID for the type name to make sure that
// different Eclipse applications use different "types" of
// <code>LocalSelectionTransfer</code>

private static final String TYPE_NAME =
"local-selection-transfer-format" +
Long.valueOf(System.currentTimeMillis()); //$NON-NLS-1$;

//more stuff

To see that:

git clone https://git.eclipse.org/r/platform/eclipse.platform.ui
Import at least org.eclipse.jface into Eclipse
Open org.eclipse.jface.util.LocalSelectionTransfer and review SonarLint warnings

Best regards, Lars

Hi,

As far as I understood you have an issue on line 9 of your code example. This rule’s implementation is based on the heuristics of finding specific characters in the comment text. In your case removal of ; will make issue disappear. I’m not sure we want to change this rule, as if we make it less sensitive (to not report for your case) we will have many more false negative. So I suggest you to edit your comment or mark it as FP in the SonarQube (if you use connected mode).

Ah! Thanks removing the ; did the trick. Thanks. Having a ; at this position is just silly so I will remove these occurrences.

This issue can be closed or marked as solved.