How to create rules from templates for tests?

I have created some rules from templates (eg S3688 “Track uses of disallowed classes” or S2253 “Track uses of disallowed methods”). These templates are defined as “Analysis scope: main sources” and all rules created from them also seem to be the same so they are not running against test code.

Is it possible to create a rule from a template and for that rule to run against test sources?

I am using Sonarqube community 26.10.0.

Hey @mzsnelling, welcome to the Community! As of today, it’s not possible, the scope (main or test) of the rule is hardcoded. Perhaps a solution on our side could be to create an equivalent rule but for test instead of main. In any case, I will flag this for the team and let them weigh in.