scitools.com

← Metric catalog

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

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

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

Unlike Average Comment Lines, this counts each function's comment lines inside inactive #if/#ifdef regions 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 0 comment lines (including inactive) and SayHello::printHello() has 2 (its // Inactive comment falls inside an inactive #ifdef block), so class SayHello's average is Average(0, 2) = 1. The file also includes cyclomaticDemo() and main(), neither of which has any comments: Average(0, 2, 0, 0) = 0.5, which rounds to 1.

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


Targets By Language: Configuration: