scitools.com

← Metric catalog

Average Code Lines (Includes Inactive) 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 Code Lines (Includes Inactive)

API ID: AvgCountLineCodeWithInactive
Languages: C++
Targets: Classes, Files

Average number of lines containing source code for all nested functions or methods, including inactive regions.

Unlike Average Code Lines, this counts each function's code lines inside inactive #if/#ifdef regions (and the preprocessor conditional lines guarding them) too, before averaging. 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 1 code line (including inactive) and SayHello::printHello() has 14 (its inactive block adds 1 inactive code line plus 2 preprocessor lines), so class SayHello's average is Average(1, 14) = 7.5, which rounds to 8. The file also includes cyclomaticDemo() (27) and main() (18, which has its own inactive block): Average(1, 14, 27, 18) = 15.

See Code Lines (Includes Inactive) for the per-function count this averages.


Targets By Language: Configuration: