我在禁用问题“最大继承深度”时遇到问题。
在声纳规则描述中,其鱿鱼为:
“ squid:MaximumInheritanceDepth”。
因此,在我的POM中,我有:

<sonar.issue.ignore.multicriteria>e11</sonar.issue.ignore.multicriteria>
<sonar.issue.ignore.multicriteria.e11.rulekey>squid:MaximumInheritanceDepth</sonar.issue.ignore.multicriteria.e11.rulekey>
<sonar.issue.ignore.multicriteria.e11.resourceKey>**/GUIpanel.java</sonar.issue.ignore.multicriteria.e11.resourceKey>


但是构建失败,显示以下错误消息:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar (default-cli) on project parent: Unable to load component class org.sonar.scanner.phases.AbstractPhaseExecutor: Unable to load component class org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader: Unable to load component class org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer: Exclusions > Issues : Invalid format. The second field does not define a rule pattern: **/GUIpanel.java,,* -> [Help 1]


据我了解,这是在告诉我,为GUIpanel类提供的排除不能执行,因为第二个字段(规则键)未定义规则模式,因此编写错误

squid:MaximumInheritanceDept


那么,什么是解决方案?

最佳答案

解决了。 ruleKey必须使用大写字母K,我将其写为:rulekey,但应为ruleKey。

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <sonar.issue.ignore.multicriteria>e11</sonar.issue.ignore.multicriteria>
    <sonar.issue.ignore.multicriteria.e11.ruleKey>squid:MaximumInheritanceDepth</sonar.issue.ignore.multicriteria.e11.ruleKey>
    <sonar.issue.ignore.multicriteria.e11.resourceKey>**/*.java</sonar.issue.ignore.multicriteria.e11.resourceKey>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <jacoco.data.file>${project.build.directory}/jacoco.exec</jacoco.data.file>
    <jacoco.report.path>${project.reporting.outputDirectory}/jacoco.xml</jacoco.report.path>
    <sonar.language>java</sonar.language>
    <sonar.jacoco.reportPaths>${jacoco.data.file}</sonar.jacoco.reportPaths>
</properties>

07-24 13:34