Semicolons 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.
Semicolons
API ID: CountSemicolonLanguages: Ada, C#, C++, Java
Targets: Architectures, Classes, Files, Functions, Packages, Project, Subprograms
Number of semicolons.
This is a simpler token count than Statements: since each clause of a for loop's header counts as its own statement, it's actually a single semicolon that can end multiple statements at once — cyclomaticDemo()'s bool a = true, b = true, c = true; declares three variables (three declarative statements) with only one semicolon. Other lines, like a block or an if without a trailing statement, have none.
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() has 6 semicolons: one ending each of the three cout statements (lines 14, 16, 19), and three inside the for loop's header on line 18 (m = 0;, m < j;, and the empty body's own ;). The semicolon on the inactive cout line inside the #ifdef block (line 23) doesn't count.
- Ada: Project, File, Type, Entry, Function, Package, Procedure, Protected, Task
- C#: Project, File, Class, Method
- C++: Project, File, Function
- Java: Project, File, Class, Interface, Method
- This metric can be disabled from "Project Configuration/Metrics/Lines and Statements" with the "Show statement count metrics" option.