I'm a fan of automated testing and code analysis utilities, but I must say they only make sense if people actually use them and look at their results. So it's not really just about integration -- it's about looking at the results of these tools. PMD is neat because it can simply interrupt your build process so you'll have to either fix the warning or explicitly mark it as ignored. With code coverage... I don't know. It's up to you guys -- you spend much more time on Nutch code than I do and you know best what is needed and what isn't.

Let me know about PMD. I'll create the patch tomorrow if there's a consensus on if and how we should use it. For those impatient, the patch is in the attachment. Place the required PMD JARs in lib/pmd-ext/ and run 'ant pmd'.

D.

Jérôme Charron wrote:
I would not be opposed to integrating PMD or something similar into
Nutch's build.xml.  What do others think?  Any volunteers?
I'll do it. I meant to see PMD anyway so it'll be a good exercise.

Dawid, what about integrating a Code Coverage Tool like EMMA (
http://emma.sourceforge.net/)
while integrating PMD ?

Jérôme

Index: build.xml
===================================================================
--- build.xml   (revision 391739)
+++ build.xml   (working copy)
@@ -198,6 +198,34 @@
   </target>
 
   <!-- ================================================================== -->
+  <!-- Run code checks (PMD)                                              --> 
+  <!-- ================================================================== -->
+  <target name="pmd">
+       <property name="pmd.report" location="${build.dir}/pmd-report.html" />
+       <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
+         <classpath>
+                 <fileset dir="${lib.dir}" includes="pmd-ext/*.jar" />
+         </classpath>
+       </taskdef>
+       <pmd shortFilenames="true" failonerror="true" 
failOnRuleViolation="false"
+                encoding="${build.encoding}" 
failuresPropertyName="pmd.failures">
+         <ruleset>unusedcode</ruleset>
+      <formatter type="html" toFile="${pmd.report}" />
+         <!-- <formatter type="xml" toFile="${tempbuild}/$report_pmd.xml"/> -->
+         <fileset dir="${src.dir}">
+        <include name="**/*.java"/>
+               <!-- Exclude generated sources -->
+               <exclude name="**/NutchAnalysis.java" />
+               <exclude name="**/NutchAnalysisTokenManager.java" />
+      </fileset>
+    </pmd>
+       <condition property="pmd.stop" value="true">
+               <equals arg1="0" arg2="${pmd.failures}" trim="true" />
+       </condition>
+       <fail unless="pmd.stop">FAILURE: PMD shows ${pmd.failures} rule 
violations. See ${pmd.report} for details.</fail>
+  </target>
+
+  <!-- ================================================================== -->
   <!-- Run unit tests                                                     --> 
   <!-- ================================================================== -->
   <target name="test" depends="test-core, test-plugins"/>

Reply via email to