When working in a large solution of a project that’s been going on for years (Sitecore project or not), there’s bound to be technical debts here and there. Technical decisions which were taken in not an ideal condition which leads to shortcuts being made, not necessarily wrong decisions but the best decisions considering the situation at the time.
So how does one maintain and improve code quality with such code base? especially when people would come and go on the project and without fully understanding the code base as a whole they would perform the bare minimum to complete the work which usually ends up as more technical debts which never gets pick-up as it gets buried deep within the code base as time goes.
There are several ways we can help reduce the on-going technical debts by:
- Increasing our test coverage (unit test, functional test, integration test)
- Doing PR review
- Implementing the boy scout rule for every PR (leave the camp ground cleaner when you first arrived)
Been digging around for the last week seeking for ways to extract the health state of a code base and get some sort of stats for which we can then define as a baseline for improvement iterations. Which then I had a quick look at what tools available and gathered my notes on SonarQube.
I first heard about SonarQube in my old company 4 years back (was called Sonar back then). I never gave much thought of it back then but now decided to have a quick look into it and so far I like what I’m seeing and the capabilities it have.
One of the main reasons why I’m so keen with this tool is that it can provides the stats that I’m looking for from the current code base, the key thing to know if you’re doing some sort of improvements you would need to have concrete parameters. Another big reason is since the tools has been around for a while and matured, it has lots of plugins – including plugins which integrate nicely to our tooling and processes.
Here’s some of my notes so far on this tool which looks pretty cool.
Integration with the developer experience
- Integrate with Visual Studio
- Integrate with Resharper
Integration with JIRA
This plugin can create JIRA tickets based on SonarQube reports. At the time of writing this plugin has been labeled as deprecated though.
Integration with Team City
This plugin offers the following features:
- Easy SonarQube Runner deployment and configuration
- SonarQube Server connections management
- Test results locator. Works for Surefire and MSTest reports at the moment
- JaCoCo coverage result locator
- Navigation to SonarQube Server from the TeamCity UI: the View in sonar link on the Build Results page takes you to the sonar dashboard of the analysed project once the build is finished.
- SonarQube`s Build Breaker plugin support
Now, you don’t really need this plugin if all you need is to run the SonarQube analysis runner and view the report in the SonarQube web application. All you need is just to execute the SonarQube analysis runner command which will generate the XML report files when you build your solution file and send it to the SonarQube server.
Integration with Bitbucket
- Extract the health state of your code base
- Highlight failed quality checks
- Instant feedback in your PR – really cool I’d say 🙂
So far it looks really promising, hopefully I can share more on this tool as I get some time to play around with it.