Average Code 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 Code Lines
API ID: AvgCountLineCodeAlso Known As: Average Method Size (AMS)
Languages: Ada, Basic, C#, C++, Fortran, Java, Jovial, Pascal, Python, Rust, Web
Targets: Classes, Files, Modules, Packages
Average number of lines containing source code 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() has 1 code line and SayHello::printHello() has 11, so class SayHello's Average Code Lines is Average(1, 11) = 6. The file also includes cyclomaticDemo() (27 code lines) and main() (14 code lines): Average(1, 11, 27, 14) = 13.25, which rounds to 13. func() is declared here but never defined, so it contributes nothing to either average.
See Code Lines for the per-function count this averages, and Average Code Lines (Includes Inactive) to also count inactive code lines before averaging.
Also known as Lorenz & Kidd - Average Method Size (AMS).
- 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.
- This metric can be disabled from "Project Configuration/Metrics/Lines and Statements" with the "Include inactive lines" option for languages that have inactive lines.