【问题标题】:Clover: unwanted code getting appended after instrumentationClover:检测后附加不需要的代码
【发布时间】:2013-11-12 22:41:39
【问题描述】:

我正在为 Checkstyle 和 PMD 使用 3.1.0 的 Clover 插件。

以下代码在检测类开始时附加

public static class __CLR3_1_0crcrhnxpu1rh{public static com_cenqua_clover.CoverageRecorder R;static{com_cenqua_clover.CoverageRecorder _R=null;try{com_cen`enter code here`qua_clover.CloverVersionInfo.An_old_version_of_clover_is_on_your_compilation_classpath___Please_remove___Required_version_is___3_1_0();if(20110531154203887L!=com_cenqua_clover.CloverVersionInfo.getBuildStamp()){com_cenqua_clover.Clover.l("[CLOVER] WARNING: The Clover version used in instrumentation does not match the runtime version. You need to run instrumented classes against the same version of Clover that you instrumented with.");com_cenqua_clover.Clover.l("[CLOVER] WARNING: 

每行检测代码都会附加以下行

__CLR3_1_0crcrhnxpu1rh.R.inc(462);

这是预期的行为吗?还是因为检测中使用的 Clover 版本与错误消息中所述的运行时版本不匹配?

【问题讨论】:

    标签: java maven plugins clover


    【解决方案1】:

    这是预期的行为吗?

    是的,这是预期的行为。与检测字节码的 Emma/Cobertura/JaCoCo 相比,Atlassian Clover 的检测基于源代码。这就是您可以看到附加说明的原因。

    参考:

    Why does Clover use source code instrumentation

    【讨论】:

      【解决方案2】:

      我可以找到这个问题的根本原因。这是因为检测代码而发生的。我有 CheckStyle、PMD、Find Bug 和 Code Coverage (Clover) 的插件。 Clover 检测代码以查找代码覆盖率。在这种情况下,Clover 首先被执行,然后是所有其他插件。因此,CheckStyle 和 PMD 也在针对检测代码运行,并抛出不相关的警告。要解决此问题,请更改插件运行的顺序或排除检测代码。

      【讨论】:

        【解决方案3】:

        您要问的问题似乎是如何让 clover 检测您的代码,以及如何让 PMD 或其他报告工具(Checkstyle、PMD、FindBugs)不使用分析源...

        在我们开始配置 cloverOutputDirectory 之前,我们也遇到过类似的问题:

        <reporting>
          <plugins>
             <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-clover2-plugin</artifactId>
                <configuration>
                  <cloverOutputDirectory>${java.io.tmpdir}/clover/</cloverOutputDirectory>
                  <!-- ... -->
                </configuration>
             </plugin>
          </plugins>
        </reporting>
        

        见:https://docs.atlassian.com/maven-clover2-plugin/latest/instrument-mojo.html

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-03-10
          • 1970-01-01
          • 1970-01-01
          • 2012-10-21
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-01-15
          相关资源
          最近更新 更多