I Did an Experiment Enforcing a Minimum Code Quality, And There Are The Results

There are tools like SonarQube that watches and enforces minimum quality standards, but are they actually helping?

David Rodenas
4 min readJun 28, 2022


Photo by charlesdeluvio on Unsplash

Some articles ago, I talked about the only utility for code coverage. It was not quality, but code coverage is one of metrics that the companies tend to enforce to its employees. For example, if the code coverage is under an arbitrary number, let's say 87%, the pull request is automatically rejected and the developer has to fix it. The claim is that establishing this minimum for the metric, the code quality improves. And of course, there is no a unique metric, there are several of them.

One year ago, while I was reviewing code delivered by undergraduates, I realize that the code quality in a laboratory session was very low. As part of the session statement, I did explain basics of clean code, like creating auxiliary functions or better descriptions for names. Although I asked to follow those good practices, and I explained that not following them would affect their grades, almost every delivery ended in big functions full of branches. Several students even lost control of their code and created infinite loops; some private tests were able to hang their programs.

As you can imagine, I rejected most of the deliveries. I wanted the students to learn, so, I decided to give them a second chance to do a good job. But of course, not for free, not with the same rules. Because of my experience with tools like SonarQube, I created an equivalent setup that automatically rejects deliveries that are not following a minimal set of quality metrics.

So, in addition to the 100% code coverage, I decided to add the following requirements:

  • Prettier formatting is mandatory: The code should be written with a consistent style everywhere, so it is easy to read.
  • Maximum cyclomatic complexity of six: Functions should not have too many branches, so they are easier to predict. The value in the previous delivery was closer to an average of forty.
  • Maximum depth of two: There cannot be whiles or ifs nested inside other whiles or ifs. It restricts the number of things that a loop or…



David Rodenas

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.