scitools.com

← Metric catalog

Declarative Code 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.

Declarative Code Lines

API ID: CountLineCodeDecl
Languages: Ada, Assembly, C#, C++, Fortran, Java, Pascal, Python
Targets: Architectures, Classes, Files, Functions, Modules, Packages, Project, Subprograms

Number of lines containing declarative source code.

Note that a line can be declarative and executable — int i = 0;, for instance.

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

}

The function signature (line 11, declaring printHello) and the for loop's initializer (line 18, declaring m) are the only declarative code lines, giving CountLineCodeDecl = 2.

See Executable Code Lines for the complementary breakdown, and Code Lines for the total.


Targets By Language: Configuration: