如何生成Checkstyle报告? [英] How to generate Checkstyle reports?

查看:1108
本文介绍了如何生成Checkstyle报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个checkstyle报告作为xml文件,并且希望生成一份html报告,其中列出了发生了多少次错误以及发生了哪些文件的错误。像这样 example

有没有工具可以做到这一点?

解决方案

如果您使用mvn来执行此操作, mvn checkstyle:checkstyle 会生成一个xml格式的报告,或者使用 -Dcheckstyle.output.format = plain 这个选项来生成纯文本。这两个只会列出错误,并不会给出任何总结。

汇总html文件位于目标目录中,但是我发现图像和CSS都丢失了,所以看起来很糟糕。

mvn网站会像您的图片一样产生HTML格式的报告。但是它也会产生大量的其他报告材料,并且需要很长时间。



我还发现了另一个问题 - mvn checkstyle:checkstyle 只会找到您的配置文件 file:// checkstyle插件配置中的协议,例如

 < plugin> 
< artifactId> maven-checkstyle-plugin< / artifactId>
< version> 2.13< / version>
<配置>
< configLocation> file:// $ {basedir} /checkstyle/checkstyle.xml</configLocation>
< / configuration>
< / plugin>

然而 mvn site 只需要一个目录,并且无法处理 file://


I have a checkstyle report as xml file and want to generate a html report which lists what kind of errors occurred how many times and in which files they occurred. Something like this example.

Is there a tool to do that?

解决方案

If you are using mvn to do this, mvn checkstyle:checkstyle will generate an xml format report, or with the option -Dcheckstyle.output.format=plain just plain text. Both of these will only list the errors and won't give any summary.

The summary html file is found in the target directory, however I found the images and the CSS are missing so it looks pretty bad.

mvn site will generate the HTML format report like your image. However it will also generate large amounts of other reporting material and takes a long time.

I've also found another problem - mvn checkstyle:checkstyle will only find your config files if you include the file:// protocol in the checkstyle plugin config, e.g.

  <plugin>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>2.13</version>
    <configuration>
      <configLocation>file://${basedir}/checkstyle/checkstyle.xml</configLocation>
    </configuration>
  </plugin>

However mvn site only takes a directory, and can't handle the file://

这篇关于如何生成Checkstyle报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆