SonarQube (v7.5) exclusions not working

exclusions
(Karl van Winden) #1

Hello,

We’re having problems setting the exclusions for our solution.

We have an Azure DevOps Build Pipeline that uses the SonarQube extension. Our Build Pipeline looks like this:

SonarQube version 7.5.0.20543 runs on an Azure VM and we have the following exclusions configured :


Note: there are no inclusions configured.

However, the exclusions do not provide the expected results. For example, I still see the folder /Content/ in the Code section in SonarQube and I have more than 321k lines of .css (of which most are third party and in the folder /Content/).

Another example you can see in the snippet below. I would expect that the /Scripts/ folder would be excluded, but they are not. There are 12293 files in the /Scripts/ folder, but there are only 5729 files excluded and that is not because of the exclusions that I have set (if we remove the exclusions I still get the 5729 files ignored message). So I can still see the Scripts folder in the Code section in SonarQube.

Scripts/kendo/cultures/kendo.culture.am-ET.js, Scripts/kendo/cultures/kendo.culture.am.js, Scripts/kendo/cultures/kendo.culture.ar-AE.js, Scripts/kendo/cultures/kendo.culture.ar-BH.js, Scripts/kendo/cultures/kendo.culture.ar-DZ.js, Scripts/kendo/cultures/kendo.culture.ar-EG.js, Scripts/kendo/cultures/kendo.culture.ar-IQ.js, Scripts/kendo/cultures/kendo.culture.ar-JO.js, Scripts/kendo/cultures/kendo.culture.ar-KW.js, Scripts/kendo/cultures/kendo.culture.ar-LB.js, Scripts/kendo/cultures/kendo.culture.ar-LY.js, Scripts/kendo/cultures/kendo.culture.ar-MA.js, Scripts/kendo/cultures/kendo.culture.ar-OM.js, Scripts/kendo/cultures/kendo.culture.ar-QA.js, Scripts/kendo/cultures/kendo.culture.ar-SA.js, Scripts/kendo/cultures/kendo.culture.ar-SY.js,
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: Excluded sources:
INFO: **/*.js
INFO: **/*.xml
INFO: **/*.css
INFO: **/*.scss
INFO: **/*.xsd
INFO: **/*.asax.cs
INFO: **/*.trc
INFO: **/*.less
INFO: **/Scripts/**/*
INFO: **/Content/**/*
INFO: **/TestData/**/*
INFO: 7461 files indexed
INFO: 5729 files ignored because of inclusion/exclusion patterns

I have tried all possible variations I could think of (e.g. **/Scripts/**/*.*, **/Scripts/**, Scripts/**, **/scripts/**, etc.) in the Source File Exclusions, but nothing seems to work. I also tried to provide the parameters in the Prepare analysis on SonarQube using sonar.exclusions, but that doesn’t work either.

Do you have any suggestions to get this working?

1 Like
(G Ann Campbell) #2

Hi,

Let’s take the Content files as an example. What path to the file does the interface show for these?

 
Ann

(Karl van Winden) #3

Hi,

Thanks for your response.

Do you mean this?

(G Ann Campbell) #4

Hi,

Yes, and thanks for the screenshot. You appear to be in a project with a module structure, and that’s likely affecting this. A year ago I’d have advised you to try configuring your exclusions at the module level, but in 7.6 we dropped support for modules within the SonarQube UI (still supported on the analysis side for contexts - e.g. Maven - where they make sense) and deprecated those configurations.

I think your best bet long term is to upgrade and re-try setting your exclusions.

 
Ann

(Karl van Winden) #5

Hi,

I’ve upgraded to SonarQube 7.7, but it still doesn’t work.
First, I’ve tried re-analyzing the project and when that did not work I’ve deleted the project and created a new one. But still, no files are excluded.

I do see a change in the folder structure in the “Code” section. However, it does not affect the exclusions.

I’ve set the following exclusions:

Logging:

Content folder in the “Code” section:

Lines of Code:
image

(G Ann Campbell) #6

Hi,

I don’t have an answer for you yet (I need to consult on a hunch I have), but I do want to clarify a couple points.

First, you are setting these exclusions at the Project level, right?

Second, just to be clear, your last two exclusions should end with *.*, so **/Scripts/**/*.*.

 
Ann

(Karl van Winden) #8

Hi,

Yes, I’m setting the exclusions in Project - Administration - General Settings - Analysis Scope.
And also with the extra /*.* it doesn’t work:

(Karl van Winden) #9

Hi,

Do you have any news on this?