【问题标题】:Findbug - ANT xslt stylesheet source code referencesFindbug - ANT xslt 样式表源代码参考
【发布时间】:2011-04-26 00:57:46
【问题描述】:

我有一个 ANT 目标,它在同一源代码上运行 findbugs 两次以生成 xml 和 html 报告

<delete dir="${findbugs.dir}"/>
<mkdir dir="${findbugs.dir}"/>        
<findbugs 
    home="${findbugs.home}"
    output="xml"
    outputFile="${findbugs.dir}/findbugs.xml"
    jvmargs="${findbugs.jvmargs}"
    timeout="${findbugs.timeout}"
    effort="${findbugs.effort}">
   <sourcePath path="${src.dir}"/>
   <class location="${build.classes.dir}"/>
</findbugs>

<findbugs 
    home="${findbugs.home}"
    output="html"
    outputFile="${findbugs.dir}/findbugs.html"
    jvmargs="${findbugs.jvmargs}"
    timeout="${findbugs.timeout}"
    effort="${findbugs.effort}">
   <sourcePath path="${src.dir}"/>
   <class location="${build.classes.dir}"/>
</findbugs>

这很愚蠢,因为可以使用 xml 报告生成 html 报告

<xslt in="${findbugs.dir}/findbugs.xml" out="${findbugs.dir}/findbugs.html" style="${findbugs.home}/default.xsl"/>

但生成的 html 报告没有正确的源代码引用。关于如何让这个工作并避免重复的 findbugs 调用的任何想法?

回答后更新

with output="xml"

<BugInstance type="REC_CATCH_EXCEPTION" priority="2" abbrev="REC" category="STYLE">
   <Class classname="com.x.y.aggregate.AggregationProperties">
      <SourceLine classname="com.x.y.aggregate.AggregationProperties" start="20" end="788" sourcefile="AggregationProperties.java" sourcepath="com/x/y/aggregate/AggregationProperties.java"/>
   </Class>
   <Method classname="com.x.y.aggregate.AggregationProperties" name="setAggregateProperties" signature="()V" isStatic="true">
      <SourceLine classname="com.x.y.aggregate.AggregationProperties" start="86" end="148" startBytecode="0" endBytecode="489" sourcefile="AggregationProperties.java" sourcepath="com/x/y/aggregate/AggregationProperties.java"/>
   </Method>
   <SourceLine classname="com.x.y.aggregate.AggregationProperties" start="140" end="140" startBytecode="308" endBytecode="308" sourcefile="AggregationProperties.java" sourcepath="com/x/y/aggregate/AggregationProperties.java"/>
</BugInstance>

with 'xml:withMessages'

<BugInstance type="REC_CATCH_EXCEPTION" priority="2" abbrev="REC" category="STYLE" instanceHash="b7a7c8f292d2a8432680a1c971fb93b3" instanceOccurrenceNum="0" instanceOccurrenceMax="0">
   <ShortMessage>Exception is caught when Exception is not thrown</ShortMessage>
   <LongMessage>Exception is caught when Exception is not thrown in com.x.y.aggregate.AggregationProperties.setAggregateProperties()</LongMessage>
   <Class classname="com.x.y.aggregate.AggregationProperties" primary="true">
      <SourceLine classname="com.x.y.aggregate.AggregationProperties" start="20" end="788" sourcefile="AggregationProperties.java" sourcepath="com/x/y/aggregate/AggregationProperties.java" relSourcepath="com/x/y/aggregate/AggregationProperties.java">
         <Message>At AggregationProperties.java:[lines 20-788]</Message>
      </SourceLine>
      <Message>In class com.x.y.aggregate.AggregationProperties</Message>
   </Class>
   <Method classname="com.x.y.aggregate.AggregationProperties" name="setAggregateProperties" signature="()V" isStatic="true" primary="true">
      <SourceLine classname="com.x.y.aggregate.AggregationProperties" start="86" end="148" startBytecode="0" endBytecode="489" sourcefile="AggregationProperties.java" sourcepath="com/x/y/aggregate/AggregationProperties.java" relSourcepath="com/x/y/aggregate/AggregationProperties.java"/>
      <Message>In method com.x.y.aggregate.AggregationProperties.setAggregateProperties()</Message>
   </Method>
   <SourceLine classname="com.x.y.aggregate.AggregationProperties" primary="true" start="140" end="140" startBytecode="308" endBytecode="308" sourcefile="AggregationProperties.java" sourcepath="com/x/y/aggregate/AggregationProperties.java" relSourcepath="com/x/y/aggregate/AggregationProperties.java">
      <Message>At AggregationProperties.java:[line 140]</Message>
   </SourceLine>
</BugInstance>

【问题讨论】:

    标签: ant findbugs


    【解决方案1】:

    output="xml:withMessages"

    来自documentation

    如果设置为“xml”(默认),则输出为 XML 格式。如果设置为“xml:withMessages”,则输出为 XML 格式,并增加了人类可读的消息。 (如果您打算使用 XSL 样式表生成报告,则应使用此格式。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-11
      • 2012-07-23
      • 1970-01-01
      • 2013-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多