scitools.com

← Metric catalog

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.

Lines

API ID: CountLine
Also Known As: Number of Lines (NL)
Languages: Ada, Assembly, Basic, C#, C++, Fortran, Java, Jovial, Pascal, Python, Rust, VHDL, Web
Targets: Architectures, Classes, Files, Functions, Modules, Packages, Project, Subprograms

Number of physical lines.

Calculated as End_Line - Start_Line + 1, so it counts every line in the entity's extent — code, comments, blank lines, preprocessor directives, and inactive regions alike.

For example:


void SayHello::printHello() {
  switch (i) {
    case 0:
      cout << "Hello World" << endl;
    case 1:
      cout << "HELLO WORLD!" << endl;
    default: // a comment here
      for (int m = 0; m < j; m++);
      cout << "hello world" << endl;
  }
#ifdef A_VERY_NICE_VARIABLE

  cout << "Inactive Line" << endl; // Inactive
#endif

}

printHello() starts at line 11 and ends at line 26, for CountLine = 26 - 11 + 1 = 16.

See Code Lines, Comment Lines, Blank Lines, Preprocessor Lines, and Inactive Lines for a breakdown by line type. For the per-language breakdown in web files, see Lines (HTML), Lines (JavaScript), and Lines (PHP).

Also known as Number of Lines (NL).


Targets By Language: Configuration: