This problem continues to bother me.
With the option //NOSONAR it is possible to disable ALL errors in a line of a C++ file.
So it was realized that there must be a way to disable errors for a single line directly in the code.
Can someone please answer the following question:
Why is there no way created for C++ to do this like in JAVA using "@SuppressWarnings(“squid:S…)”?
I don’t understand why C++ and JAVA are handled so differently in this case.
I understand your frustration @Matthias.Guelck. We looked at the problem recently and right now the direction we will be taking will be to:
deprecate the use of //NOSONAR alone
request a RuleKey (or multiple keys) to be provided like “//NOSONAR(S123, S222, …) Justification” => very similar to @SuppressWarnings(“squid:S…) but more language agnostic
automatically Open and Close as Won’t Fix issues that are silenced by this mechanism for traceability purpose
As mentioned here and elsewhere, (all?) other static code analysis tools provide such capabilities.
The most perfect implementation I know is provided by eslint.
There you can make the justification of the exception mandatory and even impose a minimum length for the explanation.
Can you estimate when such a solution will be available for Sonar?
I’m afraid I don’t know.
For a long time the need for this feature was questioned (see previous posts in this thread) and then in June there was the vague announcement by Alexandre Gigleux.
Since then: Nothing!
I have the same issue. SonarLint in VS2019 requests me to use c++20 std::cast_bit instead of reinterpret_cast in a project that is configured for c++14
It also forces me to add std::wstring solution for a windows API parameter that is of type PWSTR.
which i won’t accept cause that would add additional runtime in my driver, and 0 benefits.
Time flies, and unfortunately, we’ve had to adjust our priorities which has delayed the implementation of the solution I previously described. I waiting for the Clean Code Taxonomy and its impacts on Issue Statuses to be fully implemented and stable before moving on this topic.
We investigated the topic, and it is something we want to do at some point.
We have quite a few hot topics at the moment and I cannot give you a timeline at the moment.