Different Modules with Different issues to ignore "ignore.multicriteria"

Hello all,

My project contains several “module”
I want to apply different rules exclusion for each of them depending of my need.

I tried different way so far and nothing work, only the general rules for the code non-included inside a module are applied.

Example with a Module namded “common” :

General Rule:
sonar.issue.ignore.multicriteria=e1, e2
sonar.issue.ignore.multicriteria.e1.ruleKey=c:PPDirectiveIndentation
sonar.issue.ignore.multicriteria.e1.resourceKey=/*.c
sonar.issue.ignore.multicriteria.e2.ruleKey=c:PPDirectiveIndentation
sonar.issue.ignore.multicriteria.e2.resourceKey=
/*.h

Module Common Rule
common.sonar.issue.ignore.multicriteria=e3, e4
common.sonar.issue.ignore.multicriteria.e3.ruleKey=c:PPDirectiveIndentation
common.sonar.issue.ignore.multicriteria.e3.resourceKey=/*.c
common.sonar.issue.ignore.multicriteria.e4.ruleKey=c:PPDirectiveIndentation
common.sonar.issue.ignore.multicriteria.e4.resourceKey=
/*.h

OR Other Way

common.sonar.issue.ignore.multicriteria=e1, e2

Both way don’t work impossible to apply any ignoring-rule on “common” module
So What is the correct syntax ? It is even possible to do it per module ?

Thank you for the help!

Hi,

As you’ve discovered, exclusions are multi-value properties, and rather tricky to get right from the command line / analysis parameter side. I urge you to try setting these values via the UI, so that at least you can eliminate the property-setting syntax as a source of the problem.

Once that’s done, you can focus on the syntax of the exclusions themselves, which look a bit off to me. Under the assumption that you don’t have all your .c and .h files directly in the project root, I’d advise you try **/*.c instead of your current value, and an analogous value for your .h files. Alternately, since you want to exclude these rules for every file (now that I actually read what you’re setting), you could set **/*.* or even better, simply remove the relevant rule from your profile.

 
:slight_smile:
Ann

1 Like

Hi Ann,

My settings are a bit more complicated this was just an example and since I’m not admin off the Quality Gates and Rule the easiest way for me to change the rule is via sonar-project.properties located into a module.

Going back to my previous example

General Rule:
sonar.issue.ignore.multicriteria=e1
sonar.issue.ignore.multicriteria.e1.ruleKey=c:PPDirectiveIndentation
sonar.issue.ignore.multicriteria.e1.resourceKey= **/.

Module Common Rule
common.sonar.issue.ignore.multicriteria=e2
common.sonar.issue.ignore.multicriteria.e2.ruleKey=SomeOtherDirective
common.sonar.issue.ignore.multicriteria.e2.resourceKey=**/.

Rule e1 is applied properly over the root files (but not over the common directory which is what i want)
Rule e2 for the module common is not applied over my common directory files at all

ps: all my modules are recognized and scanned properly

How I applied e2 to common ? (without UI)

Thanks,

Hi,

Have you looked at the UI for this? I’m guessing not. If you do, you’ll find that there’s are no inputs to set module-specific issue exclusions (which is what I assume you’re trying to do with common.sonar.issue...). In short, I’m afraid you’re going to have to simply write one regex and be clever with it.

You’re probably about to ask me how to account for the modules in that regex and I’ll pre-empt you with honesty: I simply don’t know. Hopefully, there’s something in the module’s package path you can key off of (and ignore the module question altogether).

 
Ann

Hi Ann,

Ok thanks, but I believe in that case we should open bug ticket.
If there is no way to apply criteria selectively per module then this is an issue !

Jonathan

Hi Jonathan,

We’re actually planning to drop the concept of module from the ecosystem, so there’s no need to create a ticket.

 
Ann