Comment is wrongly flagged as code

// Handle {n,m}
This block of commented-out lines of code should be removed.
{n,m} is not valid Java code.
So this message is wrong.

Howdy!

Welcome to the SonarSource community. Unfortunately, I’m having some trouble understanding your problem based on the information currently available. Can you provide the following so we have more information to work with?

Which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

Example of the code or comment that is causing problems, formatted in a code block.

A copy of the error text or a screenshot.

Including that information will make it a lot easier for folks to help with this issue.

Cheers,
Josh

I use the latest version.
The code fragment is all you need.
Put somewhere in the program
// handle {1,2}

Or even //{1,2}

It’s flagged as code. Well it is not valid Java code but a valid comment

Vicky

Hey @VickyRonnen,

The detection of code-sample in comments is based on heuristics based on symbols that are used in the comment (in your case, the presence of curly braces { and }). Unfortunately, it sometimes leads to false positives. In your case, I would simply mark these issues as “Won’t Fix” or “False Positive”.

Hope this helps,
Michael

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.