如何从规则xml文件中设置Sonarqube上Checkstyle的现有规则参数?

时间:2016-11-30 08:13:15

标签: sonarqube checkstyle

我想通过根据我的参数设置我的checkstyle规则到Sonarqube。我使用语法Java中的Checkstyle Sonar插件,我的Sonar存储库使用RulesDefinitionXmlLoader从规则定义XML文件中读取。

假设我有以下规则XML文件来加载包含我自定义Checkstyle规则的Sonarqube以及Checkstyle中已存在的LineLength检查:

<rules> <rule> <key>LineLength</key> <name>Line Length</name> <description>Line Length</description> <internalKey>Checker/TreeWalker/LineLength</internalKey> <param key="max" name="Max"> <defaultValue>120</defaultValue> <description>Max property with value of '120'</description> </param> </rule> <rule> <key>CustomCheck</key> <name>CustomCheck</name> <description>any custom check</description> <internalKey>Checker/TreeWalker/CustomCheck</internalKey> <param key="anyParam" name="any"> <defaultValue>any</defaultValue> <description>any param value</description> </param> </rule> </rules>

我想在Sonarqube上使用这些规则。我的自定义规则和LineLength规则是在Sonarqube上使用给定参数创建的。我在我用过的个人资料中激活了其中两个。我的自定义规则成功地对git pull请求起作用,但LineLength检查对拉取请求不起作用。因为已经有来自Checkstyle插件的Sonarqube的LineLength检查所以Sonarqube的仪表板上出现了两个LineLength规则。但是我希望通过从Sonar规则XML文件中提供我想要的参数来覆盖现有的LineLength检查。请注意,当我激活两个LineLength规则时,其中两个成功运行但我不希望现有的LineLength规则有效,我想用我的参数检查LineLength。

0 个答案:

没有答案
相关问题