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.
Statements
| API ID | CountStmt |
| Targets | Architectures Classes Files Functions Modules Packages Project Subprograms |
| Languages | Ada Assembly Basic C# C++ Fortran Java Jovial Pascal Python Rust VHDL Web |
| Solution | Hersteller Initiative Software (HIS) |
| Categories | Statements |
| Cost | Lookup |
Number of statements.
A single physical line can contain more than one statement, and each clause of a for loop's header (initialization, condition, and increment) counts as its own statement, in addition to its body.
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;
}
main() contains 11 statements: the for loop's three header clauses (int i = 0, i < 10, i++) plus its empty body (;), the six variable declarations and assignments (int j = func();, int k = 0;, int l = 1;, int m = func();, int n;, n = 1;), and the final return 0;, for CountStmt = 11. The two statements inside the inactive #ifdef block don't count.
See Declarative Statements, Executable Statements, and Empty Statements for a breakdown by statement type, and Semicolons for the related count of ; tokens.
- 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, 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
- Rust: Project, File, Function
- VHDL: Project, File
- Web: Project, File, PHP Class, PHP Interface