Exclusions are not working for file paths with specific folder names

  • ALM used: GitHub

  • CI system used: GitHub

  • Scanner command used when applicable: Automatic Analysis

  • Languages of the repository: C#, SQL, CSS, HTML

  • Error observed:
    We are seeing analysis of files in 3rd party libraries that should be ignored. For example, our exclusions include both **/Content/**/* and **/kendo/**/* yet the path:
    [omitted part of the path for privacy]/Content/kendo/2017.2.621-source/mobile/kendo.mobile.all.css
    is being scanned. I suspect this is due to the periods in the folder name.

  • Steps to reproduce
    Create a repo with a folder similar to the above, attempt to exclude files in the folder, they will not be excluded.

  • Potential workaround
    Rename the folder to not include the periods.

Hi @JonLegendreSoluta ,

Can you tell me how you’re excluding these paths? Are you using the project configuration (via the Project Settings on SonarCloud itself), or are you using parameters in a *.properties file?

I am using the project settings → General Settings → Analysis Scope → Source File Exclusions.
Note that other similar paths are being excluded, but the files in the path with periods in the folder name are not being excluded.

Hi again,

I cannot reproduce the issue by adding a period (.) in a folder name.

Do you have source file inclusions configured? Could you list here the different paths you have configured? Note that this can be set at the instance level, too (i.e., your project configuration might not show anything specific, but your global instance configuration could have different rules).

If you run your scanner with the -X flag (debug mode), you should see in your logs something like this:

16:37:32.702 INFO: Project configuration:
16:37:32.703 INFO:   Included sources: [list of paths to include...]
16:37:32.703 INFO:   Excluded sources: [list of paths to exclude...]

It could be that you have conflicting inclusions/exclusions configured, and this could lead to analyzing files that should not be analyzed.

Also, did you try renaming that folder to not have any periods (e.g., 2017-2-621-source/)? Does it make any difference?

I suggest trying a path including 2017.2.621-source and seeing what happens.
In any case, these files were unnecessary, so I removed them, as such, I can no longer reproduce the issue nor provide logs.