Average 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.
Average Lines
API ID: AvgCountLineLanguages: Ada, Basic, C#, C++, Fortran, Java, Jovial, Pascal, Python, Rust, Web
Targets: Classes, Files, Modules, Packages
Average number of lines for all nested functions or methods.
Only functions and methods that are actually defined (not just declared) directly inside the container count towards the average, and the result rounds to the nearest whole number.
For example:
class SayHello {
public:
SayHello() {}
void printHello();
};
void SayHello::printHello() {
...
}
void cyclomaticDemo() {
...
}
int func();
int main() {
...
}
SayHello() is 1 line and SayHello::printHello() is 16, so class SayHello's Average Lines is Average(1, 16) = 8.5, which rounds to 9. The file also includes cyclomaticDemo() (29 lines) and main() (23 lines): Average(1, 16, 29, 23) = 17.3, which rounds to 17. func() is declared here but never defined, so it contributes nothing to either average.
See Lines for the per-function count this averages, and Average Code Lines, Average Comment Lines, and Average Blank Lines for the other line-type averages.
- Ada: File, Package
- Basic: File, Module, Class, Struct
- C#: File, Class, Struct
- C++: File, Class, Struct, Union
- Fortran: File
- Java: File, Class, Interface
- Jovial: File
- Pascal: File, Class, Interface
- Python: File, Class
- Rust: File
- Web: File, PHP Class, PHP Interface
- This metric can be disabled from "Project Configuration/Metrics/Lines and Statements" with the "Show line count metrics" option.