Configure Sonar sonar.issue.ignore.multicriteria through maven

自古美人都是妖i 提交于 2019-12-18 12:24:38

问题


I'm using a local instance of Sonar without a centralized infrastructure. In order to keep the configuration of my project in the pom.xml, I want to configure the project through maven and not through the Sonar UI. For me this has the advantage of keeping things in one place and other developers don't have to configure their local Sonar instance, just unpack and play.

The doc on howto configure the sonar.exclusions property through maven is readily available but the format for sonar.issue.ignore.multicriteria is unclear.

How can you configure sonar.issue.ignore.multicriteria through maven?


回答1:


After stepping through the code the format is:

<properties>
        <sonar.issue.ignore.multicriteria>e1,e2</sonar.issue.ignore.multicriteria>
        <sonar.issue.ignore.multicriteria.e1.ruleKey>squid:S00100</sonar.issue.ignore.multicriteria.e1.ruleKey>
        <sonar.issue.ignore.multicriteria.e1.resourceKey>**/*Steps.java</sonar.issue.ignore.multicriteria.e1.resourceKey>
        <sonar.issue.ignore.multicriteria.e2.ruleKey>squid:S1118</sonar.issue.ignore.multicriteria.e2.ruleKey>
        <sonar.issue.ignore.multicriteria.e2.resourceKey>**/PropertyPlaceholderConfig.java</sonar.issue.ignore.multicriteria.e2.resourceKey>
</properties>

The keys e1,e2 can be chosen arbitrarily as long as they are used with .ruleKey and .resourceKey in the depending properties.

The same works for sonar.issue.ignore.block:

 <sonar.issue.ignore.block>e1</sonar.issue.ignore.block>
 <sonar.issue.ignore.block.e1.beginBlockRegexp>@SonarIgnore</sonar.issue.ignore.block.e1.beginBlockRegexp>
 <sonar.issue.ignore.block.e1.endBlockRegexp></sonar.issue.ignore.block.e1.endBlockRegexp>


来源:https://stackoverflow.com/questions/21825469/configure-sonar-sonar-issue-ignore-multicriteria-through-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!