Code Quality – SonarQube

Jure Maleš, Senior Java Developer

Tech

16.06.2020.

featured image

Do you know that feeling when you see a code and ask yourself: „Oh my God, who wrote this bad code?“ And after browsing through history you see the unpleasant truth – the author is you. It is nothing strange; we learn every day, and we have new and better ideas which we can refactor.

If you work on some proof of concept application, or something for learning – you probably have the luxury of infinite changes. But unfortunately for application developers, in the real world there are deadlines and spending too much time on refactoring is not an option.

In addition, if you work on a bigger project and in bigger teams, you know how hard it is to have code style consistency. It can be very difficult to understand your colleague’s code and continue the work.

A very useful tool to solve these problems is SonarQube.

SonarQube is an automatic code review tool to detect bugs, vulnerabilities, and code smells in your code.

The idea of this article is not to describe how to use SonarQube – this would require a whole book. SonarQube has too many highly useful things for one blog article. You have a project in two or more different languages – no problem, SonarQube works with many of the most popular programming languages.

How to use SonarQube?

For example, you have pushed you work, but you forgot to validate a part of your code on NullPointerException. It happens. But on the SonarQube portal you get a message about this and are asked to refactor, like in the following picture.

SonarQube - code quality
Source: SonarQube

As said before, a whole book is required to describe SonarQube. Nevertheless, use it in your development process. Your developers will write cleaner, more secure codes, and they will be better developers.

Your code will be better, easier, and cheaper to maintain. And at the end, one of the most important things – your client will be satisfied.

RELATED

08.06.2020.

Monitoring in HA Applications

The key goal of monitoring is an increase in situational awareness. There is no automation without observability, and there is very little situational awareness without monitoring. The role of monitoring is to deliver observable data in a human-readable format. We can, however, extract additional value by taking a few extra steps.

Read more