What is the standard for a js project comment line?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Enterprise edition 9.9
    SonarScanner 4.6.2.2472

  • how is SonarQube deployed: zip, Docker, Helm
    Docker

  • what are you trying to achieve
    *Analyze after comments on different lines

  • what have you tried so far to achieve this
    It looks like // comments are recognizable, but not when they appear at the top of the file.

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!


Hey @honghua,

Thank you for your highly appreciated feedback!

Indeed, as you correctly guessed, the comments at the top of the file are not taken into account for the comment metrics. This is a default behavior of the JavaScript analyzer. The reason is that we assume that every source file generally starts with a license header as a comment. In your case, what’s happening is that line 4 and line 5 are considered to be such a source file header. That’s the reason why the comment count is 4 rather than 6.

Having said that, you can disable this behavior by configuring your SonarQube setup with the property sonar.javascript.ignoreHeaderComments set to false (default is true). Here is where you would do that in SonarQube’s UI:

Hope this helps,
Yassin

1 Like

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