【问题标题】:Exclude generated code in sonar在声纳中排除生成的代码
【发布时间】:2012-11-22 05:53:30
【问题描述】:

如何从声纳处理和报告中排除生成的代码?

我尝试exclude**/*generated*,但像org.blayo.generated 这样的包仍在报告中:

<plugin>
  ...
  <artifactId>maven-checkstyle-plugin</artifactId>
  <configuration>

    <excludes>**/*generated*</excludes>

编辑:正确的正则表达式是**/generated/*.java

【问题讨论】:

    标签: java maven maven-plugin sonarqube


    【解决方案1】:

    排除模式自 SonarQube 3.5 起发生了变化。下面是它现在的工作方式:

    <properties>
       <sonar.exclusions>file:**/generated-sources/**</sonar.exclusions>
    </properties>
    

    来源:SonarQube JIRA

    【讨论】:

    • 这是最终让它为我工作的模式
    • 它可以在没有 file: 前缀的情况下工作,重要的是 wildcard syntax(至少在 SonarQube 6/7 中)。使用&lt;sonar.exclusions&gt;target/generated-sources/**&lt;/sonar.exclusions&gt; 是一个小改进。
    【解决方案2】:

    为此使用sonar.exclusions 属性:

    <properties> 
      <sonar.exclusions>**/*generated*</sonar.exclusions>
    </properties>
    

    【讨论】:

      猜你喜欢
      • 2013-09-06
      • 2018-08-22
      • 2022-07-01
      • 2019-11-23
      • 1970-01-01
      • 2021-12-23
      • 2016-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多