"Shouldn’t Comment Lines + Blank Lines + Code Lines = Total Lines?


And shouldn’t declarative statements and executable statements add up to the total number of statements as well?"


These are common types of assumptions associated with metrics - however, any given line can actually count towards multiple metrics, so the numbers are not necessarily unique.


Let's take this simple example:


int deltaChange = 5; // Delta needs a minimum variant of 5


This line is both a code line and a comment line, so it counts toward both metrics. Likewise the statement is both declarative and executable, so would count in each of those metrics.


As another example, let's look at the differences between CountLineCodeDecl and CountStmtDecl.


CountLineCodeDecl is counting the number of lines containing declarative source code. Declarative code would be anything like variable declarations, function prototypes, class definitions, or namespace declarations. On the other hand, CountStmtDecl is the number of declarative statements themselves. Keep in mind that a single line can contain multiple declarative statements. So, you could for example have 1 declarative source code line with 3 declarative statements:


int x, y, z;


or, you could have 4 declarative source code lines with 2 declarative statements:


class MyClass {
public:
    void foo();
};


This difference is analogous to the difference between executable lines of code and executable statements as well. CountLineCodeExe counts the number of lines of code that contain executable statements, such as function calls, loops, and conditional statements. CountStmtExe counts the number of individual executable statements, such as "x = 5;". A single line of code can contain multiple executable statements.


Whenever in doubt about what a metric means, just click the information 'i' icon in the top right of the Metrics Browser to find an explanation for every metric. 


If you believe there are any issues with the metrics or how they are calculated, don't hesitate to email us at support@scitools.com.