Hello, I am trying to use soner.exclusions to skip analysis on a particular folder. I have a folder structure as follows. This is the contents of a git repo that has a Visual Studio solution at the root. Many of the sub folders are individual Visual studio sub projects (csproj)
I want to exclude everything under the top level utilities folder.
I have tried “**\Utilities**” but doing that excludes the other folders with similar names.
I have tried “Utilities***”, but doing so results in the warning
“Specifying module-relative paths at project level in the property ‘sonar.exclusions’ is deprecated. To continue matching files like ‘Applications/CometTray/Utilities/CommonConnectivityManager.cs’, update this property so that patterns refer to project-relative paths.”
Any guidance on how I can specifically exclude the one folder tree but not any other folders with similar names? It seems like the rules are evaluated from the root of every visual studio project, not from the root of the solution/repo
There are two things of note here. First, exclusions need to exclude files. And ** means 0-n directories. What you want is **\Utilities\**\*.* or perhaps Utilities\**\*.*
Ehm… So an exclusion starting with ‘Utilities’ is going to be relative to project/analysis root, which should work based on what you provided above. Suggesting **\Utilities\ was just a belt-and-suspenders kinda approach on my part.
TBH, I don’t know the effect of Utilities** since I read that as Utilities[0-n dir] which… I think wouldn’t resolve to anything.
If i make the path ‘Utilities**.’, I get a warning like shown below about one of the child directories in which I don’t want the rule to be applied to
Specifying module-relative paths at project level in the property ‘sonar.exclusions’ is deprecated. To continue matching files like ‘Applications/CometTray/Utilities/CommonConnectivityManager.cs’, update this property so that patterns refer to project-relative paths.
Thanks Ann. That definitely helped. I’m just not clear on how to get the rule to apply to the Root only, and not any subfolders. The documentation isn’t very clear here and a path like Utilities\**\*.* has undesired side effects of applying to any subfolders that have a Utilities folder
You know, the interface, which is what I recommend using, allows you to add multiple exclusion specifications. You can also specify multiple, comma-delimited exclusions.
Again, I guess what i’m saying it it either seems like a) there is a bug on SonarQube in how in interprets the rules, or b) I’m looking for advice for how to write the rule correctly.
You can see that I have a rule of Utilities/**/*.*
That rule correctly ignored all of the code in Utilities/FolderA/file.cs
However, that rule also incorrectly ignored the code in SubProject/Utilities/Folder2/file.cs
It seems to me that the rule is applied to every CSProj folder that occurs within a visual studio solution.
Does my problem make sense? It’s frustrating to me that I can’t get this to work.
Hi @ganncamp. Hope you had a nice holiday. I’m checking in on what needs to be don’t to properly configure a visual studio solution as a multi-module ?
@ganncamp I’m checking one last time on this. What is the guidance for these “multi-module” visual studio projects. All of our projects use this and if it’s not supported well, I need to know so that I can look for alternatives.
We were never able to get this to work as we were never given proper guidance on how to configure “multi-modules” projects. As a work around, we had edit each of the .csproj files for the projects we wanted to exclude and add an exclusion directive to those files. We feel like we shouldn’t have needed to do that but, it worked