Domanda

is there a possibility to duplicate existing checkstyle rules? I want Sonarqube to differ guideline rules.

Example:

The rule for method complexity should mark the method as [MINOR] when there is more than 10 lines of code per method and as [MAJOR] when there is more than 30 lines of code per method.

Maybe there is a particular plugin for this special case?

Thanks in advance

È stato utile?

Soluzione

This is currently a limitation in SonarQube. However, it can be done partially.

For Checkstyle based rules, you can copy some rules (those that have a Copy Rule button; screenshot here under "Multiple activation of rules"). I've personally used this for the Comment Pattern Matcher and created a rule that matches TODO comments as INFO severity and another that matches FIXME comments as CRITICAL. As I understand your question, that is what you are looking for. I don't think this is possible for all parameterizable rules, though.

Also, for PMD based rules, there is this blog post which describes how to use the XPath rule template in order to create custom PMD rules. This could be a workaround for those PMD based rules that don't have a Copy Rule button.

The feature we would need is a Copy Rule button for every parameterizable rule. AFAIK, this does not exist yet.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top