The Linting Poet

Francesco Barbera
Keep Calm and Code On
3 min readMay 7, 2018

This is an article for developers that would work better and be better for the world. If you’re a manager, it’s worth for you and for the developer you know.

When I first look at a piece of code I immediately try to find an answer to the question:

Is it good?

To find out I can for example use an automated system.

There are a lot of tools that help us to measure code quality. One of these tools is Sonar Qube, that provides a static code analyser which offers a lot of useful data. In most cases, all this information must be reduced to a number that represents the general quality of the code we have written.

My last project’s code scored 7 points out of 10, yeeee!

This number is an abstraction based on some criteria that have previously been defined. But the hidden problem with abstractions is that they have a cost, and the cost is that we lose knowledge of what is happening beyond using them. Because of this it is difficult to find a generic value in a number that is the synthesis of other metrics.

What about inverting our point of view? Not trying to find metrics that our code must follow to be considered good, but finding something that at a first look tells us if we are going in the right direction.

In my opinion, when looking at a project, a function or a for cycle, we can immediately either appreciate it or not. Have we got an instance of Sonar Qube in our brain? I don’t think so. Instead, I believe that all the nights spent reading about proper programming techniques have trained our mind to work like Sonar Qube.

Is this the solution to all the pull request deep diving? No, of course. But for me it is the first step. For this reason, I try to grow a sort of taste for the code I write. And for example, looking at some code which I wrote one year ago makes me feel sad, probably because I now produce better code.

And what about the different approaches of my colleagues? It is quite impossible to have the same experience and so the same code-beauty meter. But I think that reasoning on code quality leads to a reciprocal improvement and a sort of automatic linting check.

In conclusion for me, the beauty of code is the first tool used to verify the quality of our work and appreciating a beautiful code helps us in finding a way to write better code. Futhermore thinking as a benefit software developer I’m studying and tracking how different metrics like Cyclomatic Complex is directly proportional to Carbon Footprint. The more you put cycles into cycles, the more you’re wasting energy. I’m collecting this data to prove that quality and code beauty is also impacting on the environment.

Enjoyed this post? Subscribe to our newsletter and get all updates delivered to your inbox in a handy once a month message!

--

--