An introduction to static code analysis using Sonar

Posted on: Oct 2, 2021 Written by DKP

Good programmers write code for humans first, and computers next

No idea who said that above line, or if anyone said it at all before I stole it off the internet, but damn right it is.

Code changes more often than I change my mind(which is saying something), and it's almost certain that the next change to the code you're writing right now, will be done by someone other than you. In such a case, ensuring that code is readable, maintainable, follows a set of standard practices becomes critical.

In a large organization with a crazy big codebase worked on by multiple teams and developers, the problem is exacerbated - no one really knows who wrote the code they are having to debug, and thus, it does save a lot of WTFs if the code follows coding practices.

So now the question comes - who ensures developers follow standard practices? You can't give all developers a book of rules, and ask them to refer to it before each variable name they type. There is a need for a tool that checks code as the developer types, and points out the issues and the flaws

And this tool, is called Sonar.