NOSONAR not working on TypeScript

Wondering what is the position now. Its been more than a year and // NOSONAR is not working on (Typescript) project.

Hi @bhantol

I moved your message to a new thread since it has IMO no relations with quick fixes. I just give a quick try, and // NOSONAR is working fine in TypeScript files.

Please share a bit more details so that we could help you: what is your IDE? What is the version of SonarLint? Are you using connected mode?

My IDE is VACode.
I am using SonarQube 7.9 (in process of upgrading to 8.9)

NOSONAR not working on Javascript files.

Sonar version 9.1

How can we ignore certain lines of code of SONAR. In js.

Hello,

Sorry for the late response.

I tried on my side and it works. I used the following code:

let a = 0;
let b = 0; // NOSONAR
let c = 0;

Could you check on your side ?

This is on the sonar ui showing the Issues

  • Community Edition
  • Version 8.9.6 (build 50800)

what sonar issue were you expecting for Sonar in your example anyway for let b = 0; ?
I am not seeing any issues raised in your example with or without // NOSONAR

Hello @bhantol ! As documented in the FAQ, you need to put //NOSONAR at the end of the line of the issue. From your screenshot it seems like //NOSONAR is positioned on the line above the issue.
Could you please try and see if it works for you this way?
Thanks!

3 Likes

I’m facing the same issue. But in my case it’s inside an object.
No matter where I add the //NOSONAR comment (end of line, end of sub object, after semicolon) it’s not recognized and though connected to server, the issue only appears inside VS Code, so I cannot handle it through the server.

Please see my example:

export const environment: EnvironmentRef = {
  firebase: {
    apiKey: '<some_key_here>', // NOSONAR
  }, // NOSONAR
  production: false
};// NOSONAR

Error is secrets:S6334. In that case a false positive.

Hello @Tom4U, welcome to the Sonar Community! :sonar:

I tried to reproduce your issue but couldn’t. I am able to see secrets:S6334 raised on the line of the apiKey, and putting // NOSONAR at the end of the line re-triggers analysis and gets rid of the issue. Could it be that you need to wait a bit more to see the issue disappear? :thinking:

And yes, secrets analysis, for now, is only part of SonarLint, not yet available on SonarQube.

Best,
Sophio

Hey Sophio, ok that’s really weird. I’ve switched back and forth, restarted extension host. But somehow it’s really not updating the state and sometimes it does. However. at least it’s not shown anymore as constant warning.

Still there seem to be a few performance issues I guess.

Indeed it sounds weird :thinking: ,

Please feel free to create a new post under SonarLint > VSCode category with all the details that could be relevant in case the issue persists.

Have a great day :smiling_face:,
Sophio

1 Like

Recently had an issue, using nestjs & typescript I got a quality gate failure due to duplication of decorators across different endpoints. I tried using the // NOSONAR comment to ignore the offending lines of code - this worked for my branch, but the quality gate failed once I merged into main, is there any known issues with this? thanks

Hello , I tried adding the // NOSONAR at the end of the constructor method . But its not working .

Hello @Avanti, :sun_with_face:

I believe you should place the comment at the end of line 37 and the issue should be muted. Since this thread is for SonarLint VSCode, if your issue keeps re-appearing, I suggest opening a new thread in the SonarQube category. :smiling_face:

Best,
Sophio