Findbug - ANT XSLT样式表源$ C ​​$ C参考 [英] Findbug - ANT xslt stylesheet source code references

查看:213
本文介绍了Findbug - ANT XSLT样式表源$ C ​​$ C参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行FindBugs的两次相同的源$ C ​​$ C生成一个XML和HTML报告Ant目标

 <删除DIR =$ {} findbugs.dir/>
< MKDIR DIR =$ {} findbugs.dir/>
< FindBugs的
    家=$ {} findbugs.home
    输出=XML
    OUTPUTFILE =$ {} findbugs.dir /findbugs.xml
    jvmargs =$ {} findbugs.jvmargs
    超时=$ {} findbugs.timeout
    努力=$ {} findbugs.effort>
   < SOURCEPATH PATH =$ {}对于src.dir/>
   <类位置=$ {}的build.classes.dir/>
< / FindBugs的>< FindBugs的
    家=$ {} findbugs.home
    输出=HTML
    OUTPUTFILE =$ {} findbugs.dir /findbugs.html
    jvmargs =$ {} findbugs.jvmargs
    超时=$ {} findbugs.timeout
    努力=$ {} findbugs.effort>
   < SOURCEPATH PATH =$ {}对于src.dir/>
   <类位置=$ {}的build.classes.dir/>
< / FindBugs的>

这是愚蠢的,因为HTML报告可以从XML报告使用生成

 < XSLT中=$ {} findbugs.dir /findbugs.xml走出=$ {} findbugs.dir /findbugs.html的风格=$ {FindBugs的。家里} /default.xsl/>

但生成的HTML报告不正确的源$ C ​​$ C引用。我如何能得到这个工作,避免重复FindBugs的呼唤吗?任何想法

答案后更新

 带输出=XML< BugInstance TYPE =REC_CATCH_EXCEPTION优先=2缩写=REC类别=STYLE>
   < className类=com.x.y.aggregate.AggregationProperties>
      <源极线类名=com.x.y.aggregate.AggregationProperties开始=20结尾=788的资源文件=AggregationProperties.java源路径=COM / X / Y /骨料/ AggregationProperties.java/>
   < /类>
   <方法的类名=com.x.y.aggregate.AggregationPropertiesNAME =setAggregateProperties签名=()VisStatic =真>
      <源极线类名=com.xyaggregate.AggregationProperties开始=86结尾=148startByte code =0endByte code =489的资源文件=AggregationProperties.java源路径= COM / X / Y /骨料/ AggregationProperties.java/>
   &所述; /方法>
   <源极线类名=com.xyaggregate.AggregationProperties开始=140结尾=140startByte code =308endByte code =308的资源文件=AggregationProperties.java源路径= COM / X / Y /骨料/ AggregationProperties.java/>
< / BugInstance>与XML:withMessages< BugInstance TYPE =REC_CATCH_EXCEPTION优先=2缩写=REC类别=STYLEinstanceHash =b7a7c8f292d2a8432680a1c971fb93b3instanceOccurrenceNum =0instanceOccurrenceMax =0>
   <&的ShortMessage GT; /&的ShortMessage GT;如果没有抛出异常&LT异常被捕获;
   < LongMessage>在异常不com.x.y.aggregate.AggregationProperties.setAggregateProperties抛出的异常被捕获()< / LongMessage>
   < className类=com.x.y.aggregate.AggregationProperties初级=真>
      <源极线类名=com.xyaggregate.AggregationProperties开始=20结尾=788的资源文件=AggregationProperties.java源路径=COM / X / Y /骨料/ AggregationProperties.javaSourcepath =COM / X / Y /骨料/ AggregationProperties.java>
         <消息>对于AggregationProperties.java:[lines 20-788] LT; /信息>
      < /源极线>
      <消息>在类com.x.y.aggregate.AggregationProperties< /信息>
   < /类>
   <方法的类名=com.x.y.aggregate.AggregationPropertiesNAME =setAggregateProperties签名=()VisStatic =真正的主=真>
      <源极线类名=com.xyaggregate.AggregationProperties开始=86结尾=148startByte code =0endByte code =489的资源文件=AggregationProperties.java源路径= COM / X / Y /骨料/ AggregationProperties.javaSourcepath =COM / X / Y /骨料/ AggregationProperties.java/>
      <消息>在方法com.x.y.aggregate.AggregationProperties.setAggregateProperties()< /信息>
   &所述; /方法>
   <源极线类名=com.xyaggregate.AggregationProperties初级=真开始=140结尾=140startByte code =308endByte code =308的资源文件=AggregationProperties的.java源路径=COM / X / Y /骨料/ AggregationProperties.javarelSourcepath =COM / X / Y /骨料/ AggregationProperties.java>
      <消息>对于AggregationProperties.java:[line 140] LT; /信息>
   < /源极线>
< / BugInstance>


解决方案

输出=XML:withMessages

文档


  

如果设置为XML(默认值),输出是XML格式。如果设置为xml的:withMessages,输出与人类可读的消息增强XML格式。的(你应该如果你打算使用生成XSL样式表报表中使用这种格式。)


I have an ANT target that runs findbugs twice on the same source code to generate a xml and html report

<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>

This is dumb since the html report can be generated from the xml report using

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

but the generated html report doesn't have the correct source code references. Any ideas on how I can get this working and avoid the duplicate findbugs call?

Updated after answer

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>

解决方案

output="xml:withMessages"

From the documentation,

If set to "xml" (the default), output is in XML format. If set to "xml:withMessages", output is in XML format augmented with human-readable messages. (You should use this format if you plan to generate a report using an XSL stylesheet.)

这篇关于Findbug - ANT XSLT样式表源$ C ​​$ C参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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