scitools.com

← Metric catalog

Average Blank 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 Blank Lines

API ID: AvgCountLineBlank
Languages: Ada, Basic, C#, C++, Fortran, Java, Jovial, Pascal, Python, Rust, Web
Targets: Classes, Files, Modules, Packages

Average number of blank 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() has 0 blank lines and SayHello::printHello() has 1, so class SayHello's Average Blank Lines is Average(0, 1) = 0.5, which rounds to 1. The file also includes cyclomaticDemo() (2 blank lines) and main() (4 blank lines): Average(0, 1, 2, 4) = 1.75, which rounds to 2. func() is declared here but never defined, so it contributes nothing to either average.

To also count blank lines inside inactive regions before averaging, use Average Blank Lines (Includes Inactive). See Blank Lines for the per-function count this averages.


Targets By Language: Configuration: