Measuring Code Quality

Code quality is vital for true continuous delivery in an agile environment.  Teams need to be sure that their code quality is at a standard that will not break the build in order to allow fast progression to live.  Teams also need to ensure they have a good quality continuous integration / continuous delivery pipeline.

In order to assess code quality across the business you will need to set a baseline.  From that baseline outline steps to show both the improvement of the team and of the business as a whole.

I used the grid below to work with my clients key service teams to create a code quality maturity baseline.

Code Quality Metrics

The example baseline table below gives clear indications of where effort was required for improvement  1.  In each of the teams (Viewing vertically) and 2.  where to focus effort across the business as a whole (Viewing horizontally).

Maturity Grid

Initially teams may be resistant, they may not want to discuss ‘code quality’ and have their service reviewed.  Work with Senior Team members to make it clear that the purpose of the review is not for reprisal, but to see where the business is currently and how the collective could improve and deliver benefit to the customer.  Combine this with a demonstration of the benefits of TDD (Test Driven Development), good Unit Test Coverage and the use of tools like stylecop and sonarqube through a working scrum team delivering shippable software on a two weekly sprint cycle to change attitudes.

In my experience, teams will began to look to the demonstration scrum team for ‘what good looks like’, joining the scrum ceremonies especially the retrospectives.

For my client, shippable code quality improved with the teams taking part in the programme.   Commits did not progress if they broke the build and acceptable test coverage was set at 80%.