Different regex for different files

Using the “Ignore Issues on Multiple Criteria” option under Project Settings → Analysis Scope, I can tell SQ to ignore a specific rule for files matching a given regex.

For regex-based rules, what I’d like to do is use one regex for files matching the given pattern, and another regex (such as the default) for any other file. Is this possible?

Specifically, we’re using the Java rules in the low 100’s that refer to naming conventions for field names, method names, etc., which take a regex parameter. For certain groups of files we have valid reasons for violating the standard regex and would like to use a different regex.

If we switch the rule to the new regex then a lot of names in other files would become issues. We could make a regex that ORs the two together, but then any violation of the STANDARD rules in files outside of the special group would be ignored if it happened to conform to the new regex (i.e., a false negative).

We could ignore the rule for the special files but then we’d miss any violations THERE. So adjusting the rule according to the file pattern would be the most optimal.

(If worse comes to worst, we can just script something to pick out the special cases and mark them wontfix using the web_api. But I wanted to check first.)


Sorry, but what you’re after isn’t natively supported. (Normally I’d say it’s not possible, but you’ve already been quite creative in describing possibilities :smiley: ). The topic of activating parameterized rules multiple times in a profile with different parameter values (and usually different severities) is one that comes up occasionally, but not often enough to have gathered any steam.


Thanks. As it turns out, for the rule we were interested in, there were so many exceptions in those specific files that making a regex that matched them all would be equivalent to .* more or less. So we just turned off the rule for certain files matching a pattern.

1 Like