Software managers and technical leaders need insights on their code quality. Ideally, code quality should improve over time, or at least not get worse. In this article, we explain why it is important to keep track of your software metrics and how you can measure and improve them.
Why measure software metrics?
One key objective of a technical lead or a manager of a software development team is to ensure that the quality of a codebase is improving over time or at least doesn’t get worse. In order to do so, it is important to keep track of key software metrics.
“If you can’t measure it, you can’t improve it.” — Peter Drucker
There are opposing views on which metrics should be used to measure software quality. The following metrics are widely accepted in the software engineering community:
- Code smells: code smells represent bad patterns or insecure functions in the code.
- Length: functions should be small with a clear scope to be easily understandable. A good rule of thumb is that you should be able to see a function on your monitor without scrolling. While there is no single value that fits all languages (see the Martin Fowler post about this), functions should often not exceed more than 50 lines of code.
- Complexity: code should stay simple in order to be easy to understand and maintain. The cyclomatic complexity measure is considered a good metric to measure code complexity.
- Security issues: list of all security issues such as secret key exposure or storing credentials in an insecure manner.
Keeping track of these metrics will ensure that (1) your code does use bad or insecure patterns and (2) is maintainable.
How can you measure them?
The best way to measure your code metrics is to rely on Codiga. Codiga keeps track of all important software metrics (code smell, security issues, complex and long functions) at each code change (code push) and surfaces them in graphs so that you can track their evolution over time.
Codiga also allows you to look at multiple branches of the same project in order to compare these quality metrics on different flavors or versions of your code. It also keeps track of the type of code smells and their severity (in order to prioritize issues). Finally, it also allows you to compare your code quality against popular open source projects in order to evaluate your code quality against popular and well-written projects.
Measuring your code quality metrics and keeping track of them over time is critical in order to guarantee your software quality improves over time. Not all metrics are useful, but the consensus in the software engineering community is that code smells, code complexity and length of code are useful metrics. Codiga helps you record your metrics on all code platforms such as Gitlab or Bitbucket and is available either in a cloud version or in a dedicated enterprise instance for your own GitHub, Bitbucket or GitLab instance.