File exclusion added, but still analyzed?

Hi,

In one of our projects we want to exclude all css files currently stored in a folder called FranceFiles. When we add **/FranceFiles/*.css to the exclusion, they still get included in the analysis. Any ideas?
Folder where the css resides is: Src/XXX.YYY/Tests/XXX.YYY.Common.Tests/Helpers/FranceFiles

That exclusion pattern looks good to me, as a value for the sonar.exclusions scanner parameters.

Can you please clarify:

  • How do you scan your project?
  • How exactly do you specify the exclusion pattern?

Hi @janos,
We use Azure DevOps (cloud version), and have the Sonarcloud extension installed. Build is done by MSBuild.
We have the following Coverage exclusion:
image

and the following file exclusion:
image

Hi @janos if you need more details, please indicate.

There are two types of “file” exclusions, source and test. Which one is it, can you please clarify?

Also, what do you use to compute coverage in css files?

Hi,

It is the source file exclusion that we use. Right now we are not yet looking into the coverage of css files.

Hi @janos, if you have any info on what we can best do, please indicate. Right now we set all issues to resolve as won’t fix, but would be better if we got the file exclusion to work.

Hi @zaat, sorry about the late response. When you say the files still get included in the analysis, how do you mean exactly? What are you observing that makes you think this is the case? For example, do you see those files on the Code tab on SonarCloud? (For the record, I was not able to reproduce the issue, files seem to get correctly excluded with that kind of pattern, regardless of directory depth.)

Hi @janos,
I just setup an additional (new) project for the team that is experiencing the issue. With the same code, same exclusions, same issue persists. I can send you the details of the team/org/appl if you want to investigate?

Yep, I see the code in the code-tab

Files under folders named Tests are considered test files, which is different from source files. To exclude these CSS files, please use the Test File Exclusions setting.

Let me know if you need more help.

Hi @janos,

Thanks for checking. I tried, when I put **/FranceFiles/*.css in the test file exclusion it only works if I add the same location in the source file exclusion.
So only as source file exclusion, or only as test file exclusion does not work. Then these files are analyzed. Only if I add the exclusion on both (Source file and test file) they are excluded. Does seem like something to fix I think ?
Anyway, works for me now. Thanks for your support!