Main Content

Number of Executable Lines

Number of executable lines in function body

Description

This metric measures the number of executable lines in a function body. When calculating the value of this metric, Polyspace® excludes declarations, comments, blank lines, braces or preprocessing directives. In cases where the same logical statement spans multiple lines of code, Polyspace counts each line that contains executable code as one executable line. For example, this code contains two executable lines:

totalPower = voltage * current + 
                offset - losses;  // counted as 2 executable lines

If the function body contains a #include directive, the included file source code is also calculated as part of this metric.

This metric is not calculated for C++ function templates and lambdas. For these entities, the value is reported as Not computed.

Examples

expand all

void func(int, double);

	int getSign(int arg) {//Excluded
	int sign; //Excluded
	static int siNumber = 0; //Excluded
	double dNumber = 5;//Excluded
	if(arg<0) {
		sign=-1;
		func(-arg,dNumber);
		++siNumber;
		/* func takes positive first argument */   //Excluded
	}//Excluded
	else if(arg==0)
	sign=0;
	else {
		sign=1;
		func(arg,dNumber);
		++siNumber;
	}//Excluded
	return sign;
}//Excluded

In this example, the number of executable lines of getSign is 11. The calculation excludes:

  • The definition of the function.

  • The variable declarations.

  • The comment /* ... */.

  • The lines with braces only.

Metric Information

Group: Function
Acronym: FXLN
HIS Metric: No

Version History

expand all