Semi-colons in comments detected as "commented out code"

Rule “cpp:S125” is firing inappropriately and detecting a code smell when a comment line ends in a semi-colon.

In the example commentary below sonar detects two commented out code-lines and reports them as two separate code smells.

///
/// This class provides the minimum exception guarantee;
/// in the event of exceptions
/// it will not leak resources or break class invariants.
/// This is a concrete class;
/// it is not intended to be used as a base class.
///

This might be a grammar smell but it should not be a code smell.

Hi @KantarBruceAdams ,
Indeed, the heuristic we use to detect code will sometime confuse text ending with a semicolon with commented out code. I added your example to our ticket about the subject.
Thanks for reporting that.

1 Like