scitools.com

← Metric catalog

Average Lines is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.

Average Lines

API IDAvgCountLine
TargetsClasses Files Modules Packages
LanguagesAda Basic C# C++ Fortran Java Jovial Pascal Python Rust Web
AggregationAverage
CategoriesLines
CostQuery

Average number of lines for all nested functions or methods.

Only functions and methods that are actually defined (not just declared) directly inside the container count towards the average, and the result rounds to the nearest whole number.

For example:

class SayHello {
public:
  SayHello() {}
  void printHello();
};

void SayHello::printHello() {
  ...
}

void cyclomaticDemo() {
  ...
}

int func();
int main() {
  ...
}

SayHello() is 1 line and SayHello::printHello() is 16, so class SayHello's Average Lines is Average(1, 16) = 8.5, which rounds to 9. The file also includes cyclomaticDemo() (29 lines) and main() (23 lines): Average(1, 16, 29, 23) = 17.3, which rounds to 17. func() is declared here but never defined, so it contributes nothing to either average.

See Lines for the per-function count this averages, and Average Code Lines, Average Comment Lines, and Average Blank Lines for the other line-type averages.


Targets By Language: