Falsely classified as commented-out code: // MARK: - delete[] -- always noexcept

`The following line is classified as commented-out code:

// MARK: - delete[] -- always noexcept

In my opinion, this is a false positive, as this is nowhere near code.
Is it the square brackets? the noexcept keyword?

I work predominantly with Xcode and use // MARK: - // MARK: separators quite often.

Sonarcloud, C/C++ Code
Rule cpp:S125

I’m neither working for Sonar, nor am I a C++ programmer, but I know (from the .NET code base) more or less how this rule is (most likely) implemented. Long story short, it is a relatively loose educated guess, and for good reasons: you do not want to spend to many computations on this one.

As as far as I know, there are for - the multiple languages it has been implemented in - not too many false positives. If they try do change the analysis base on this report, I can not tell.

That all being said, I think it is a false positive, and an easy work around will most likely be:

/// MARK: - delete -- always noexcept

Hi @Sidelobe ,

Thanks for raising this point.

As @Corniel mentioned, this rule is based on pretty loose heuristics and can fail. But we could probably add an exception for anything tagged // MARK:.
I’m not sure when this will be prioritized, but I created a ticket to track that task.

2 Likes

Thanks @Fred_Tingaud, much appreciated!

In a similar style, Xcode also has special handling for // TODO: and // FIXME: – but this behaviour is (partially) shared with most other IDEs (Clion, Eclipse, …).

However, since a least // TODO: is already covered by S1135, it probably makes sense to include these tags as exceptions as well.

1 Like

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