scitools.com

← Metric catalog

Declarative Statements 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 Statements

API IDCountStmtDecl
TargetsArchitectures Classes Files Functions Modules Packages Project Subprograms
LanguagesAda Assembly Basic C# C++ Fortran Java Jovial Pascal Python VHDL Web
CategoriesStatements
CostLookup
TagsProject Summary

Number of declarative statements.

A statement that both declares a variable and initializes it with a function call counts as both declarative and executable.

For example:

int main() {
  for (int i = 0;
       i < 10;
       i++)
    ;

  int j = func();
  int k = 0;
  int l = 1;

  int m
    = func();
  int n;
  n = 1;

#ifdef A_VERY_NICE_VARIABLE

  int j = 0;
  cout << j << endl;
#endif

  return 0;
}

The six variable declarations — int i (the for loop's own initializer), int j = func();, int k = 0;, int l = 1;, int m = func();, and int n; — are all declarative, for CountStmtDecl = 6. int j = func(); and int m = func(); also count as executable, since each calls func().

See Executable Statements for the complementary breakdown, and Statements for the total. For the per-language breakdown in web files, see Declarative Statements (JavaScript) and Declarative Statements (PHP).


Targets By Language: