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 ID | CountStmtDecl |
| Targets | Architectures Classes Files Functions Modules Packages Project Subprograms |
| Languages | Ada Assembly Basic C# C++ Fortran Java Jovial Pascal Python VHDL Web |
| Categories | Statements |
| Cost | Lookup |
| Tags | Project 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).
- Ada: Project, File, Type, Entry, Function, Package, Procedure, Protected, Task
- Basic: Project, File, Method, Module, Class
- C#: Project, File, Class, Method
- C++: Project, File, Class, Struct, Union, Function
- Fortran: Project, File, Module, Block Data, Function, Program, Subroutine
- Java: Project, File, Class, Interface, Method
- Jovial: Project, File, Module, Subroutine
- Pascal: Project, File, Class, Interface, Compunit, Function, Procedure
- Python: Project, File, Class, Function
- VHDL: Project, File
- Web: Project, File, PHP Class, PHP Interface