What are source code metrics?

Source code metrics is a core instrument that we use in Source Code Analysis.

Source code metrics can be divided to Statistical metrics and Quality metrics. Today there are many metrics used for both mentioned groups. Actually each metric represented by some rule or algorithm is used for its calculation.

codEnforcer supports at the moment the following quality metrics:

  • Coupling;
  • Afferent Coupling;
  • Efferent Coupling;
  • Instability;
  • Relational cohesion;
  • Abstractness;
  • Lack of Cohesion of Methods (standard and Henderson-Sellers);
  • Distance from the Main Sequence;
  • Association between classes;
  • Metrics of level of compliance with OOP paradigms.

Metrics for level of compliance with OOP paradigms introduced by us are for conducting deep analysis of source code developed on C++ and PHP. These metrics help understand the level of object oriented programming usage in this source code because it may contain parts developed basing on structured programming approach. All metrics used in codEnforcer applicable for source code developed on C++, C#, PHP and Java. In total codEnforcer has now 225 different metrics realized.

Each quality metric provides estimation for some property of source code, for example its coupling or abstractness. Only one metric doesn’t provide any understanding about general quality of source code. It makes sense to use many metrics which can cover different aspects of source code statement. More important is to have ability to check dynamics of changes for these metrics during some period of time. With this approach it is possible to understand in what direction the development of your source code goes. codEnforcer in Server Based version provides appropriate tool for tracking dynamics of source code development.

If you look at the chart you can see how in 2-3 steps of source code analysis with codEnforcer source code quality trend can be determined. And if it isn’t moving into right direction, you’ll be required to make changes in source code basing on recommendations provided in by the system. With this approach you will be able to save a lot of time for source code improvement on later stages of development.

Source code metrics are directly connected with source code quality and statement. This means that such properties of source code as stability, reliability, scalability are strongly connected with metrics. Improving source code from the side of metrics means that you will improve source code from the side of its stability, reliability and scalability.

We constantly work on expanding the list of source code metrics and conduct active research to invent new metrics, new approaches for using them, to improve approaches for building recommendations and conducting source code analysis. Our research is aimed at constant improving of all theory related to source code analysis, metrics and source code optimization.