Specifying Sonar Exclusions for folder that begins with a dot (.)

Among the several folders that need to be excluded for our scans, there is a folder that begins with a dot. It does not get excluded automatically and my attempts to escape the dot with a backslash and/or enclosing it with quotes did not succeed. If it matters, it is the .storybook folder mentioned in the list below and it contains a tsconfig.json that leads to a bunch of errors when scanned.


Hey @gischethans

What system are you performing analysis on (Mac / Windows / Linux)?

Hi @Colin, I am using a Windows build agent through the Azure DevOps pipeline.

Thanks for the clarification.

There’s an interesting history here – we used to exclude such directories by default on all operating systems, but stopped doing so for Windows some time back since on Windows, files with a name starting with a dot are not necessarily hidden.

And, having just tried it on an Azure DevOps Pipeline, an exclusion of sonar.exclusions=.storybook/**/* worked exactly as expected, hiding the folder.

1 Like

Strangely, that doesn’t seem to work at my end. From the logs,

INFO: Excluded sources: **/node_modules/**/*, **/*.d.ts, **/*bundle.js, .storybook/**

Further down in our logs,
INFO: Analyzing 1286 files using tsconfig: C:\a\4\s\.storybook\tsconfig.json

Interestingly, the .storybook contents don’t show up in the SonarQube dashboard. I have already tried .storybook/**/, .storybook/ etc.

Hm… maybe our search for a tsconfig.json file doesn’t care about what is excluded for analysis. I’ll flag this for some expert attention.

1 Like

Hi @gischethans ,

Indeed we don’t ignore tsconfig in this case, there is a ticket already to fix this behavior Rely on sonar file system API to discover tsconfig files · Issue #3034 · SonarSource/SonarJS · GitHub
Thanks for sharing!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.