I setup a new CI build with SonarQube analysis this week and noticed right off there were far more lines of code for the project than I was expecting.

So I reviewed the code tree in SonarQube and noticed several very large third party JavaScript files were being included in the analysis like jQuery, bootstrap, Kendo, etc. Obviously this isn’t my code so there is little value in analyzing it (if you trust the source) and it skews my code metrics. Thankfully SonarQube provides a configuration options to control what is analyzed under General Settings | Analysis Scope:

There are many options on this page. In my case I needed to exclude source files. SonarQube uses a nice wildcard syntax to make exclusion easier:

We used the following exclusions to ignore the third party source files:

**/*kendo*/**/*

**/*jquery*

With this change our Lines of Code looked much better:

Faster Too!

The unexpected but happy byproduct of this change was our build analysis times went from 16 minutes to 6 minutes with this single change. So now the cost of analysis is effectively free on our CI build where before it caused a 10 minute penalty.

If this post was helpful, you have questions or you want to share your results/experience please leave a comment below. Thanks!

Happy Analyzing!



