In Angular project, SonarQube Analyses counts line of space, line of braces etc into LOC

  • SonarQube Server Community Edition version 25.3.0.104237
  • SonarQube Scanner 3.1.0.1141
  • SonarQube Server deployed in Docker
  • SonarQube Scanner 3.1.0.1141 in Jenkins in Docker

Executed “npm run sonar” succesfully. for Typescript Angular Project.
However, I find that in the analyses in SonarQube portal, the number Line of Code is same as the total number of line of code in a page. In other words the analyses also count line of space, line of braces etc into LOC.

How would I set so that the analyses do not count on line of space, line of braces etc. into LOC ?

Hey there.

The “algorithm” (if you can call it that) counts any line of code that is not whitespace, nor a comment. It’s expected that lines only including {/} are counted. It would not be expected that empty lines (or lines only inculding whitespace) are counted.

You’ll see the project has 3 Lines of Code (as noted on the Code tab), but 4 Lines (as shown in the file viewer).