Refactoring Code to Pass Sonar Qube’s Cognitive Complexity Checks

SonarQube and similar code quality and security tools are so much blessing

Felix Otoo
Level Up Coding
Published in
6 min readMay 9, 2021

--

Photo by ThisisEngineering RAEng on Unsplash

SonarQube and other quality check software are a blessing.

Without them, we end up deploying code with an awful lot of bugs, dead code, unreachable code, code smells, security vulnerabilities, and much more.

A lot of developers’ initial impression and experience with code quality tools is that they introduce needless friction and bottlenecks to the development and deployment processes.

We consider the friction and bottlenecks introduced to our development and integration workflow as a slash to developer productivity.

For now, you are pardoned to hold on to this strong premature consideration until you experience the substantial rewards from these tools.

Integrating code quality tools such as SonarQube into your development process can from the onset seem frustrating and counter-productivity, since you are suddenly responsible for fixing all the issues that are being flagged by the tool. Issues that must be resolved in order to pass CI/CD pipeline checks.

A lot of these issues would have made their way into production and later create run-time issues, code…

--

--