Possible Bug in scanner?

I’m using Sonarqube DevEdition 9.3
I’ve setup three rules based of the template "Track comments matching a regular expression typescript:S124 "

All are configured like this
regExp: .*foo.*
flags: i
message: some kind of message

regExp: .*bar.*
flags: i
message: some kind of message

regExp: .*test.*
flags: i
message: some kind of message

But if i scan the following code, the scanner always finds only 2 violations for one of the three rules

// foo Comment1
// todo foo Comment2
// bar Comment3
// todo bar Comment4
// test Comment5
// todo test Comment6

If i deactivate the matching rule, then the scanner suddenly finds 2 violations for one of the remaining two rules…

Is this a bug or can i have only one rule activated based on typescript:S124?

Welcome :slight_smile:

you may have 1-n rules created from a rule template.
Maybe there’s a problem with your regex.
For testing you might use https://regex101.com/

Please provide more details about what the regex should match exactly.

Which is the matching rule ?

Gilbert

Hi…
the regExp is always .*SomeWord.* and the flag i … for all the three rules…
So .*foo.* should match the lines

// foo Comment1
// todo foo Comment2

That means, 2 code smells… The other 2 rules are should match the other 4 lines of my code snippet.

So, what i expect for the code snippet are 6 Code Smells in Sonar, but i only get 2 code smells triggered by one of the 3 rules.
The other 2 rules don’t trigger a code smell… if i now deactivate the one which triggers then suddenly one of the two remaining rules triggers 2 code smells… and the last rule doesn’t trigger…

Hope this explains my problem

Hey @schlundus

This is a known issue with multiple template rules that you can track here: Fix having multiple template rules (S124) · Issue #2681 · SonarSource/SonarJS · GitHub

Thanks… that seems to be my problem

Hi Colin,

good to know.
I don’t use typescript:S124 template, but other templates like i.e. java:S3688 and never hit those
problems.
Is this bug only relevant for typescript:S124 or for templates in general ?
Are there other templates with that problem ?

Gilbert

It only affects Typescript.