Distinction between Lines and Lines of Code in C# projects

metrics
csharp

(Anantha Madhava) #1

Hello SonarQube Gurus,

We are using SonarQube V6.7.4 with SonarC# V7.2 and MSBuild for SonarQube Scanner V4.3.2.
We did this upgrade recently and observed the Lines, Lines of Code and Duplications calculations seem to have differed totally than SonarC# V5.1 which we were using earlier.

  1. I have a project in C# containing some XML and XSD files as well. Only XSD and XML files are considered as Lines of Code and C# files are considered for Lines measure.

I expected to have 99199 + 4115 as my total Lines of Code. What is the difference between Lines and Lines of Code. I read through the Metric definitions documentation but it was not clear for me.

  1. For another C# project, under the Size Measures, I see only Lines, Files and Directories and miss the other details like Lines of Code, Comments% when I know there are inline comments in the files.

  2. The Duplications have been shown as 0.0% for most of my C# projects. I suspect this issue is related to the above two questions.

Please help me understand this.

Regards,
Anantha


(Anantha Madhava) #2

Hello SonarQube Gurus,

It would be great if I get some insights into the problem I have stated above.

Waiting to hear from you guys…

Regards,
Anantha


(Nicolas Bontoux) #3

Hi Anantha,

As far as the distinction goes between Lines and Lines of Code, the Metric Definitions documentation is indeed the best resource:

Number of physical lines that contain at least one character which is neither a whitespace nor a tabulation nor part of a comment.

(meaning that comments are not counted against Lines of Code)

To the specific situation you’re observing though I don’t think there’s a generic reason for it. Looks like you’re rather in for troubleshooting it a bit, and first of all make sure that you’re closely following recommendations to analyze C# code , especially in terms of having your VisualStudio fully built as part of the analysis process.