سؤال

I'm using 3.1.0 of Clover plugin for Checkstyle and PMD.

Following code is getting appended on starting of the instrumented class

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: 

and following line is getting appended with each line of instrumented code

__CLR3_1_0crcrhnxpu1rh.R.inc(462);

is it expected behavior ? or it is because of the Clover version used in instrumentation does not match the runtime version as stated in error message ?

هل كانت مفيدة؟

المحلول 2

I could find the root cause for this issue. It's happening because of instrumented code. I have plugin for CheckStyle, PMD, Find Bug and Code Coverage (Clover). Clover instruments the code to find the code coverage. In this case Clover is getting executed first and then all other plugins. As result of this, CheckStyle and PMD are running against instrumented code as well and throwing irrelevant warnings. To solve this, either change the order in which plugin runs or exclude the instrumented code.

نصائح أخرى

is it expected behavior ?

Yes, this is an expected behaviour. In contrast to Emma/Cobertura/JaCoCo which are instrumenting bytecode, the Atlassian Clover's instrumentation is based on a source code. This is a reason why you can see additional instructions.

Reference:

Why does Clover use source code instrumentation

It seems like the question you're asking is how do you get clover to instrument your code, and PMD or other reporting tools (Checkstyle, PMD, FindBugs) to not use the analyze source...

we were having issues like this too until we started configuring the 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>

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top