Developers use metrics to gain insight into the overall health of their codebase and solutions, but it isn’t always clear what metrics they should use. To help, Codacy, an automated code review and code analytics provider, released a free e-book: “Software Metrics: A Practical Guide for the Curious Developer.”
According to Jaime Jorge, CEO and cofounder of Codacy, “Software metrics are important because they help answer questions like: Is the code tested? Is it readable? How easy is it to add or modify code without introducing bugs? Is it more complex than it needs to be? How maintainable is it going to be? Is it resource efficient? Is it easily extensible? Is technical debt creeping up? They complement the developers’ qualitative judgment with objective, quantifiable measurements to support the myriad of decisions they make daily.”
The e-book is designed to be a cheat sheet for developers in a hurry who need a practical list of useful metrics. According to Jorge, developers either don’t track their metrics or spend too much time looking at the wrong ones. “This cheat sheet allows our readers, users and customers to quickly compare and grasp what metrics are important and which are not,” he said.
“We also grade the metrics in terms of value for developers in hopes of saving time in selecting the right KPIs to track.”
The e-book goes over structural quality metrics rather than functional quality metrics. According to Codacy, functional quality metrics determine how well the software works based on what it was designed for, while structural quality metrics assess the quality of the codebase and structure.
The metrics, listed
Cyclomatic complexity: A measure of code complexity. “Cyclomatic complexity is a simple way to flag bits of code that are too complex and therefore need to be reviewed,” according to the e-book. According to Codacy, while it is useful, developers should be careful because different tools can measure the complexity in different ways.
Code churn: The number of lines added, modified or deleted. “Code churn helps quantify the amount of change that is occurring in the project,” according to the e-book.
Code coverage: A measure of code quality. Codacy notes code coverage is only as good as the quality of tests that accompany it. In addition, developers should aim for a minimum threshold of 80% code covered.
Code duplication: The amount of times code is repeated within the codebase. Codacy notes developers should try to aim for zero duplication as duplicated code can make it hard for them to read and maintain their code.
The e-book also looks at bad and obscure metrics, and how developers can either gain value from them, or why they should stay away from them.
“We’ve tried to gather a comprehensive collection of metrics that are useful to measure quality, and actionable to make decisions,” said Jorge. “Based on our understanding of how our customers use our product, we see that these metrics are some of the most important KPIs that teams should be tracking.”