Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube JavaScript disable a part of code

I would like to disable a block of code(say a function) in a file for analysis by SonarQube... Any suggestions on how to do that..

I found something for java here --> Turning Sonar off for certain code

like image 798
computnik Avatar asked Mar 15 '26 03:03

computnik


2 Answers

As far as I know Sonar respects // NOSONAR tag for Java projects but it looks like that is also has been implemented for JS: https://jira.sonarsource.com/browse/SONARJS-294

like image 170
Rafal Wiliński Avatar answered Mar 16 '26 16:03

Rafal Wiliński


To ignore blocks:

 // BEGIN-NOSCAN
const YourFunction () => {
  // Your code
}
 // END-NOSCAN

To ignore single lines:

const YourCode = 'Example'; // NOSONAR

You can read more about it here in the SonarQube docs Narrowing the Focus. Thanks to Nicolas's answer above.

like image 33
Ian Avatar answered Mar 16 '26 18:03

Ian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!