2

我正在尝试将 checkstyle 用于 java 项目,但我似乎无法使其正常工作:

虽然它显然运行顺利,但 html 报告并没有按应有的方式为每个作者提供任何信息,即作者表是空的。

问题是我不知道 checkstyle 如何识别作者。它是否查看 java doc 标签 @author ?在类级别还是在方法级别?

我使用的蚂蚁任务如下:

<taskdef resource="checkstyletask.properties" classpath="${libs.dir}/checkstyle-all-5.0.jar"/>
<target name="checkstyle" description="Generates a report of code convention violations.">
        <mkdir dir="${checkstyle.dir}"/>
    <checkstyle config="${util.dir}/checkstyle/sun_checks.xml" failureProperty="checkstyle.failure" failOnViolation="false">
        <formatter type="xml" tofile="${checkstyle.dir}/checkstyle_report.xml"/>
        <fileset dir="${src.dir}" includes="**/*.java"/>
    </checkstyle>
  <xslt in="${checkstyle.dir}/checkstyle_report.xml" out="${checkstyle.dir}/checkstyle_report.html" style="${util.dir}/checkstyle/checkstyle-author.xsl"/>
</target>

非常感谢您的帮助

大卫

4

2 回答 2

0

请注意,我没有对此进行测试,我只是author在阅读 Checkstyle 的文档时遇到了一些关于标签的内容(在你提到过一段时间之前测试它之后!)。从文档中:

检查类和接口定义的 Javadoc 注释。默认情况下,不检查作者或版本标签。要验证的范围是使用 Scope 类指定的,默认为 Scope.PRIVATE。要验证另一个范围,请将属性范围设置为其中一个 Scope 常量。要定义作者标签或版本标签的格式,请将属性 authorFormat 或 versionFormat 分别设置为正则表达式。

和:

要配置对 @author 标记的检查:

<module name="JavadocType">
   <property name="authorFormat" value="\S"/>
</module>
于 2010-03-09T07:33:41.923 回答
0

最后,我放弃了……联系了这段贡献的代码的作者,但没有回复。改为使用更简单的模式 checkstyle-simler.xsl

于 2010-03-16T14:21:01.463 回答