0

I'd like to know if there is a way to avoid having sonarQube reporting a "Code Smell" issue when a local variable is assigned and not used (writing javascript, in this case nodeJS)?

Why do I want to do that ?: for example because during WIP on code, I know some variables will be needed & used but the code using them is not yet written.

Using ESLint I can remove the error with an ESLint statement like this one:

/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "^_tbu_" }]*/

so that a statement like

var _tbu_myVar = getSomething();

without using _tbu_myVar will not raise an ESLint error.

So my question is: how can I do that using sonarQube ? Thanks

fckbo
  • 157
  • 3
  • 13
  • 2
    Teoretically you can activate or deactivate rules from your [quality profile](https://i.imgur.com/rEUDsuC.png), but for that you need admin rights, ofc. The rule I think is [Unused local variables and functions should be removed](https://i.imgur.com/jzduI5H.png) – Mara Black Nov 20 '19 at 08:11
  • In general defining code to be used in the future is not a good development practice. – Jeroen Heier Nov 20 '19 at 18:46
  • @Elias, thx but I do not want to remove this rule for the entire code. Just want to deactivate it in particular area of the code for special purpose. – fckbo Nov 22 '19 at 03:09
  • 2
    Hmm, ok.. than maybe this can help [turning-sonar-off-for-certain-code](https://stackoverflow.com/questions/10971968/turning-sonar-off-for-certain-code) or this one [ignoring-a-line-with-sonar](https://stackoverflow.com/questions/35741259/ignoring-a-line-with-sonar) or this [sonarqube-javascript-disable-a-part-of-code](https://stackoverflow.com/questions/38991670/sonarqube-javascript-disable-a-part-of-code) If you didn't read this questions already xD – Mara Black Nov 22 '19 at 08:36
  • 1
    Thx a lot Elias, the //NOSONAR was what I was looking for – fckbo Nov 25 '19 at 23:18

0 Answers0