Comment 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.
Comment Lines
| Also Known As | Comment Lines of Code (CLOC) |
| API ID | CountLineComment |
| Targets | Architectures Classes Files Functions Modules Packages Project Subprograms |
| Languages | Ada Assembly Basic C# C++ Fortran Java Jovial Pascal Python Rust VHDL Web |
| Categories | Lines |
| Cost | Lookup |
| Tags | Project Summary |
Number of lines containing a comment.
A line only counts if it is active. This can overlap with other code counting metrics — for instance int j = 1; // comment has a comment, is a source line, is an executable source line, and is a declarative source line.
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 default: // a comment here line (17) is the only active comment line. The // Inactive comment on the cout line inside the #ifdef block doesn't count because that line is inactive, giving CountLineComment = 1.
To also count comments inside inactive regions, use Comment Lines (Includes Inactive). For the per-language breakdown in web files, see Comment Lines (HTML), Comment Lines (JavaScript), and Comment Lines (PHP).
Also known as Comment Lines of Code (CLOC).
- 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
- Rust: Project, File, Function
- VHDL: Project, File, Procedure, Function, Process, Architecture
- Web: Project, File, PHP Class, PHP Interface