Sonar Checkstyle导入:无法在“质量”配置文件上激活规则模板 [英] Sonar Checkstyle import: Rule template can't be activated on a Quality profile

查看:642
本文介绍了Sonar Checkstyle导入:无法在“质量”配置文件上激活规则模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用现有的checkstyle规则集创建新的质量配置文件,但收到错误消息:

I'm trying to create a new quality profile with existing checkstyle ruleset but get the error message:


规则模板无法可以在质量配置文件上激活:
checkstyle:com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck

Rule template can't be activated on a Quality profile: checkstyle:com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck

I使用 checkstyle官方网站中最简单的规则集示例:

I use the simplest ruleset example from the checkstyle officail site:

<module name="Checker">
    <module name="JavadocPackage"/>
    <module name="TreeWalker">
        <module name="AvoidStarImport"/>
        <module name="ConstantName"/>
        <module name="EmptyBlock"/>
    </module>
</module>

版本:声纳4.5.1和Checkstyle插件2.1.1

Versions: Sonar 4.5.1 with Checkstyle plugin 2.1.1

出什么问题了?

推荐答案

这些Checkstyle规则(例如 ConstantNameCheck)定义了多个基数在SonarQube Checkstyle插件中。这意味着应该可以使用这些参数的不同值来激活这些规则的多个实例。

Those Checkstyle rules (like "ConstantNameCheck") are defined with a multiple cardinality in the SonarQube Checkstyle plugin. This means that it should be possible to activate several "instances" of those rules with different values for its parameters.

在SonarQube 4.4+中,不再可能这些规则的多次激活。它们被视为 规则模板,这意味着您必须创建自定义规则(带有显式参数),以便能够在质量配置文件上激活它们。

In SonarQube 4.4+, it is no more possible to have multiple activations of those rules. They are considered as "rule templates", which means that you must create custom rules (with explicit parameters) out of them in order to be able to activate them on quality profiles.

规则文档页面

这篇关于Sonar Checkstyle导入:无法在“质量”配置文件上激活规则模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆