Maven checkstyle违规计数

问题描述 投票:0回答:2

如何在运行maven任务时让Checkstyle打印出发现的违规总数?例如,我现在只计算每次运行后发现的违规次数。

为了澄清,我只想在我的maven任务结束时这样做:

Checkstyle found XXX violations

Checkstyle配置:

<build>
 <plugins>
  <plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-checkstyle-plugin</artifactId>
   <version>2.17</version>
   <executions>
    <execution>  
     <id>checkstyle</id>
      <phase>validate</phase>
      <goals>
       <goal>check</goal>
      </goals>
      <configuration>
       <failOnViolation>true</failOnViolation>
       <configLocation>/path</configLocation>
       <maxAllowedViolations>100</maxAllowedViolations>
      </configuration>
     </execution>
    </executions>
   </plugin>
  </plugins>
 </build>
maven checkstyle
2个回答
0
投票

在Eclipse之外使用“mvn checkstyle:checkstyle”命令构建项目。并在/ Your_Project / target / site文件夹中打开生成的checkstyle.html。您可以看到完整的报告。


0
投票

有一种替代方法可以做同样的事情,它会返回实际的数字。要做到这一点,您所要做的就是将允许的违规次数更改为0并运行mvn clean install这应该运行您的checkstyle插件并最终失败。然后,它将显示与允许的违规次数相比的违规次数。

© www.soinside.com 2019 - 2024. All rights reserved.