Manage Your Technical Debt With Visual Studio 2015 And SonarQube

What is Technical Debt

Everybody wants to write good quality code and adhere to coding standards. However in the pursuit of delivering a product within a designated timeline, we often end up with the following major problems,

  • Breaching coding standards
  • Violating design principles
  • Increasing Code Complexity
  • Lack of refactoring in the code base
  • Duplicating code across multiple files in a project
  • Lack of Unit Tests

Over a period of time, we keep building all these bad practices and end up increasing the Technical Debt. Technical debt creates unplanned work that halts progress or future development.

How can you measure Technical Debt

By using Visual Studio 2015, Team Foundation Server and its integration with SonarQube, we now have a way to measure technical debt, track it, understand the trends, stop it from growing, and manage it down.

SonarQube is an Open Source tool for continuous inspection of code quality.

It allows us to constantly measure code quality & identify technical debt, as well as gather metrics on that debt so that we can make informed decisions on how we want to approach it.

Currently one of the biggest advantage of SonarQube is its integration with Build in TFS.

We can also tie this into our gated check-in process so that we can reject code changes that fall outside our quality threshold.

What are the details that SonarQube shows

I have installed SonarQube in my local machine and performed a code inspection on my .NET Project, so that I can figure out what my Technical Debt is.

Let’s go briefly on the information which SonarQube displays,

High Level statistics of your project – Lines of Code, Code Duplication, Code Complexity metrics, Unit Test Coverage, Issues in the code and the overall Technical Debt — all in one place.

LOC

Code Duplication

CodeComplexity

Test Coverage

The computation of technical debt is based on the SQALE (Software Quality Assessment based on Lifecycle Expectations) methodology.

We can see the technical debt ratio as well as the estimated time to correct. However, this is a very rough estimate and a proper solution to each issue may require more or less time.

Debt 

There are a number of rules that are executed against the source code, for quality inspection. Please find below a sample rule set for C# language,

Rules Set 

Clicking on each rule will show us the instances where there are violations in our source code. It will also display the rule details and a compliant code example to help us resolve the problem.
 
Rule Details 

There is also a provision to compare two snapshots of Technical Debt over a period of time. This helps us to understand how our debt and code quality changes over time.

Differential 

SonarQube can add a great amount of value to our development pipeline as well as give the business, the metrics it need to make informed decisions regarding investments and technical debt. I have been using SonarQube in our project for doing our Code Reviews and have found it very beneficial. We can write our own custom rules too. I would suggest you to get started with SonarQube to manage your technical debt and let me know if you have any questions – I would be happy to help.


Similar Articles