SonarTS icon indicating copy to clipboard operation
SonarTS copied to clipboard

Configure RuleType mapping for external rules

Open mum-viadee opened this issue 5 years ago • 2 comments

I want to request a feature.

Hi, in our project we import tslint issue reports (see #619) in our CI pipeline. All external issues (eg. from tslint-microsoft-contrib) are imported as RuleType.CODE_SMELL. It would be nice, if there could be a possibility to configure a mapping between Rule and Type for external rules.

mum-viadee avatar Jun 18 '19 12:06 mum-viadee

@mum-viadee thanks for the request. We will think about it. Do you already see any way for us to do it? There is ruleSeverity property available for each issue (error or warning). But I'm not sure how it can be used for rule type.

vilchik-elena avatar Jun 18 '19 15:06 vilchik-elena

Hi @vilchik-elena , thanks for your quick response. I thought of how one could configure the needed mapping for the external issues and came to two solutions:

  1. Create a configuration view in SonarQube to configure SonarTS and add external rules with name, type and default severity.

  2. Add the possibility to place an optional configuration file (e.q. sonarts.json) in the workspace where the mapping between external rule name, rule type and default severity can be configured.

Both solutions would work identically only the way and place the mapping is configured is different. The configured mapping should be used by SonarTS to import external rule issues. The rule name would be the key to look up the type and default severity in the configuration.

The hard-coded mapping, as it is today could be the fallback if no configuration is found for an imported external issue.

I know that the rule names are not unique, so there could be collisions between external ans build-in rules. If so, the build-in mappings for SonarTS rules should have higher priority than the configured ones. If one rule name is configured more than once, the first occurrence of the rule mapping should be used.

mum-viadee avatar Jun 21 '19 14:06 mum-viadee