# The rule "Track uses of "NOSONAR" comments" does not behave as expected

**URL:** <https://community.sonarsource.com/t/the-rule-track-uses-of-nosonar-comments-does-not-behave-as-expected/74895>\
**Category:** SonarQube Server / Community Build\
**Tags:** sonarqube, cfamily\
**Created:** [October 21, 2022, 1:39pm UTC](https://community.sonarsource.com/t/the-rule-track-uses-of-nosonar-comments-does-not-behave-as-expected/74895 "2022-10-21T13:39:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stef](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@Stef](https://community.sonarsource.com/u/Stef)\
**Post date:** [October 21, 2022, 1:39pm UTC](https://community.sonarsource.com/t/the-rule-track-uses-of-nosonar-comments-does-not-behave-as-expected/74895/1 "2022-10-21T13:39:11Z")

</div>

SonarQube 8.9.6

Hello,

The C++ rule cpp:S1291 "Track uses of “NOSONAR” should actually find all places in the code that are marked with NOSONAR. However, this only works if the NOSONAR is in a block comment and not if it is in a line comment.

The NOSONAR is recognized in lines 43, 60 and 75, but not in lines 49 and 68.

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/2/b/2bea1b807deb61291f7b1986107ffa70ff31e5c5.png)

---

<div class="post-metadata">

**Author:** ![JolyLoic](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jolyloic/32/199_2.png) [@JolyLoic](https://community.sonarsource.com/u/JolyLoic)\
**Post date:** [November 8, 2022, 3:58pm UTC](https://community.sonarsource.com/t/the-rule-track-uses-of-nosonar-comments-does-not-behave-as-expected/74895/3 "2022-11-08T15:58:29Z")

</div>

Welcome @Stef,

This is indeed an issue in our analyzer, which is already known as [[CPP-2049] - Jira](https://sonarsource.atlassian.net/browse/CPP-2049). The problem is not directly related to block-comments vs line-comment, but the fact that if a line contains `NOSONAR`, all issues on this line will be silenced, even issues that report that this line contains `NOSONAR`…

This problem was never considered as high-priority to fix, because the recommended way to silence issues is not to use `NOSONAR`, but to mark it as _Won’t fix_ or _False positive_ in the UI. This is preferred for the following reasons:

- It avoids cluttering the source code.
- `NOSONAR` is a blunt tool, that will not work nicely when a line contains several issues
- Even if an issue is corrected, `NOSONAR` comments may remain, thus confusing the readers of the code

Hope this helps!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [November 18, 2022, 11:34am UTC](https://community.sonarsource.com/t/the-rule-track-uses-of-nosonar-comments-does-not-behave-as-expected/74895/5 "2022-11-18T11:34:11Z")

</div>

Closed on November 18, 2022, 11:34am UTC

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