]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added Checkstyle 4.0 capability. Added Checkstyle autodetection.
authorJoerg Pietschmann <pietsch@apache.org>
Tue, 20 Sep 2005 11:16:59 +0000 (11:16 +0000)
committerJoerg Pietschmann <pietsch@apache.org>
Tue, 20 Sep 2005 11:16:59 +0000 (11:16 +0000)
Use checkstyle.home.dir in build-local.properties to point to the
checkstyle home.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@290420 13f79535-47bb-0310-9956-ffa450edef68

build.xml
checkstyle-4.0.xml [new file with mode: 0755]

index 80d3caddb3cbd20dbf2e59dce37ab19c612e1e2e..eef9121170f45f1392a4f3e7e26d3665f602bdbd 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -127,15 +127,6 @@ list of possible build targets.
     </fileset>
   </path>
 
-  <path id="checkstylepath">
-    <fileset dir="${basedir}/lib">
-      <include name="checkstyle-all-*.jar"/>
-    </fileset>
-    <fileset dir="${optional.lib.dir}">
-      <include name="checkstyle-all-*.jar"/>
-    </fileset>
-  </path>
-
   <patternset id="exclude-jimi">
     <exclude name="org/apache/fop/image/JimiImage.java" unless="jimi.present"/>
   </patternset>
@@ -818,25 +809,104 @@ list of possible build targets.
   <!-- =================================================================== -->
   <!-- Checkstyle                                                          -->
   <!-- =================================================================== -->
-  <target name="checkstyle" depends="codegen" description="Runs Checkstyle for a code quality report">
-    <available property="checkstyle.available" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" classpathref="checkstylepath"/>
-    <fail message="Please put checkstyle-all-*.jar in the lib directory. Get it from http://checkstyle.sourceforge.net" unless="checkstyle.available"/>
-    <taskdef name="checkstyle" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" classpathref="checkstylepath"/>
+  <property name="checkstyle.home.dir" value="${optional.lib.dir}"/>
+  <property name="checkstyle.noframes.xslt" value="${checkstyle.home.dir}/contrib/checkstyle-noframes.xsl"/>
+
+  <path id="checkstyle-path">
+    <fileset dir="${basedir}/lib">
+      <include name="checkstyle-all-*.jar"/>
+      <include name="checkstyle-*.jar"/>
+      <include name="antlr*.jar"/>
+      <include name="commons-beanutils*.jar"/>
+      <include name="commons-collections*.jar"/>
+      <include name="commons-logging*.jar"/>
+      <include name="jakarta-regexp*.jar"/>      
+    </fileset>
+    <fileset dir="${checkstyle.home.dir}">
+      <include name="checkstyle-all-*.jar"/>
+      <include name="checkstyle-*.jar"/>
+      <include name="antlr*.jar"/>
+      <include name="commons-beanutils*.jar"/>
+      <include name="commons-collections*.jar"/>
+      <include name="commons-logging*.jar"/>
+      <include name="jakarta-regexp*.jar"/>      
+    </fileset>
+    <!--fileset dir="${optional.lib.dir}">
+      <include name="checkstyle-all-*.jar"/>
+      <include name="checkstyle-*.jar"/>
+      <include name="antlr*.jar"/>
+      <include name="commons-beanutils*.jar"/>
+      <include name="commons-collections*.jar"/>
+      <include name="commons-logging*.jar"/>
+      <include name="jakarta-regexp*.jar"/>      
+    </fileset-->
+  </path>
+
+  <path id="checkstyle-runpath">
+    <path refid="checkstyle-path"/>
+    <fileset dir="${basedir}/build">
+      <include name="fop.jar"/>
+      <include name="fop-hyph.jar" />
+    </fileset>
+  </path>
 
-    <checkstyle config="checkstyle-3.5-fop-head.xml" failonviolation="false"
-                classpathref="libs-run-classpath">
+  <target name="checkstyle-avail" depends="init">
+    <available property="checkstyle.available" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" classpathref="checkstyle-path"/>
+    <available property="checkstyle.4.x" classname="com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck" classpathref="checkstyle-path"/>
+    <available property="checkstyle.noframes.xslt.available" file="${checkstyle.noframes.xslt}"/>
+    <condition property="checkstyle.message" value="Checkstyle 4.x Support PRESENT">
+      <and>
+        <equals arg1="${checkstyle.available}" arg2="true"/>
+        <equals arg1="${checkstyle.4.x}" arg2="true"/>
+      </and>
+    </condition>
+    <condition property="checkstyle.message" value="Checkstyle 3.x Support PRESENT">
+      <equals arg1="${checkstyle.available}" arg2="true"/>
+    </condition>
+    <condition property="checkstyle.message" value="Checkstyle Support NOT Present">
+      <not>
+        <equals arg1="${checkstyle.available}" arg2="true"/>
+      </not>
+    </condition>
+    <echo message="${checkstyle.message}"/>
+    <condition property="checkstyle.config" value="checkstyle-4.0.xml">
+      <equals arg1="${checkstyle.4.x}" arg2="true"/>
+    </condition>
+    <condition property="checkstyle.config" value="checkstyle-3.5-fop-head.xml">
+      <not>
+        <equals arg1="${checkstyle.4.x}" arg2="true"/>
+      </not>
+    </condition>
+    <condition property="checkstyle.noframes.xslt.message" value="Checkstyle HTML style sheet support PRESENT">
+      <equals arg1="${checkstyle.noframes.xslt.available}" arg2="true"/>
+    </condition>
+    <condition property="checkstyle.noframes.xslt.message" value="Checkstyle HTML style sheet support NOT Present">
+      <not>
+        <equals arg1="${checkstyle.noframes.xslt.available}" arg2="true"/>
+      </not>
+    </condition>
+    <echo message="${checkstyle.noframes.xslt.message}"/>
+  </target>
+
+  <target name="checkstyle-check" depends="checkstyle-avail, codegen" if="checkstyle.available">
+    
+    <taskdef name="checkstyle" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" classpathref="checkstyle-runpath"/>
+    <!--checkstyle config="checkstyle-3.5-fop-head.xml" failonviolation="false"
+                classpathref="checkstyle-path"-->
+    <checkstyle config="checkstyle-4.0.xml" failonviolation="false"
+                classpathref="checkstyle-runpath">
       <fileset dir="${src.java.dir}" includes="**/*.java"/>
       <formatter type="plain" toFile="${build.dir}/checkstyle_report.txt"/>
       <formatter type="xml" toFile="${build.dir}/checkstyle_report.xml"/>
     </checkstyle>
-    <available property="checkstyle.stylesheet.available" file="checkstyle-noframes.xsl"/>
-    <antcall target="checkstyle-html"/>
   </target>
 
-  <target name="checkstyle-html" if="checkstyle.stylesheet.available">
-    <style in="${build.dir}/checkstyle_report.xml" out="${build.dir}/checkstyle_report.html" style="checkstyle-noframes.xsl"/>
+  <target name="checkstyle-html" depends="checkstyle-avail, checkstyle-check" if="checkstyle.noframes.xslt.available">
+    <style in="${build.dir}/checkstyle_report.xml" out="${build.dir}/checkstyle_report.html" style="${checkstyle.noframes.xslt}"/>
   </target>
 
+  <target name="checkstyle" depends="checkstyle-avail, checkstyle-check, checkstyle-html" description="Runs Checkstyle for a code quality report"/>
+
   <!-- =================================================================== -->
   <!-- Creates the distribution                                            -->
   <!-- =================================================================== -->
diff --git a/checkstyle-4.0.xml b/checkstyle-4.0.xml
new file mode 100755 (executable)
index 0000000..23ba909
--- /dev/null
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+<module name="Checker">
+  <module name="TreeWalker">
+    <module name="RegexpHeader">
+      <property name="headerFile" value="checkstyle.header"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="ArrayTypeStyleCheck">
+      <property name="javaStyle" value="true"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="ModifierOrderCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="RedundantModifierCheck">
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="METHOD_DEF, VARIABLE_DEF"/>
+    </module>
+    <module name="UpperEllCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="AvoidNestedBlocksCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="EmptyBlockCheck">
+      <property name="option" value="text"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, STATIC_INIT"/>
+    </module>
+    <module name="LeftCurlyCheck">
+      <property name="maxLineLength" value="100"/>
+      <property name="option" value="eol"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, METHOD_DEF"/>
+    </module>
+    <module name="NeedBracesCheck">
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="LITERAL_DO, LITERAL_ELSE, LITERAL_IF, LITERAL_FOR, LITERAL_WHILE"/>
+    </module>
+    <module name="RightCurlyCheck">
+      <property name="option" value="same"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="LITERAL_CATCH, LITERAL_ELSE, LITERAL_TRY"/>
+    </module>
+    <module name="DoubleCheckedLockingCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="EmptyStatementCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="EqualsHashCodeCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="HiddenFieldCheck">
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF"/>
+      <property name="ignoreConstructorParameter" value="true"/>
+      <property name="ignoreSetter" value="true"/>
+    </module>
+    <module name="InnerAssignmentCheck">
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="ASSIGN, BAND_ASSIGN, BOR_ASSIGN, BSR_ASSIGN, BXOR_ASSIGN, DIV_ASSIGN, MINUS_ASSIGN, MOD_ASSIGN, PLUS_ASSIGN, SL_ASSIGN, SR_ASSIGN, STAR_ASSIGN"/>
+    </module>
+    <module name="MissingSwitchDefaultCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="RedundantThrowsCheck">
+      <property name="allowSubclasses" value="false"/>
+      <property name="allowUnchecked" value="false"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="SimplifyBooleanExpressionCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="SimplifyBooleanReturnCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="FinalClassCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="HideUtilityClassConstructorCheck">
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="VisibilityModifierCheck">
+      <property name="packageAllowed" value="false"/>
+      <property name="protectedAllowed" value="true"/>
+      <property name="publicMemberPattern" value="^serialVersionUID"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="AvoidStarImportCheck">
+      <property name="severity" value="error"/>
+    </module>
+    <module name="JavadocMethodCheck">
+      <property name="allowMissingParamTags" value="false"/>
+      <property name="allowMissingReturnTag" value="false"/>
+      <property name="allowMissingThrowsTags" value="false"/>
+      <property name="allowThrowsTagsForSubclasses" value="false"/>
+      <property name="allowUndeclaredRTE" value="false"/>
+      <property name="scope" value="protected"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="METHOD_DEF, CTOR_DEF"/>
+    </module>
+    <module name="JavadocTypeCheck">
+      <property name="scope" value="protected"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="CLASS_DEF, INTERFACE_DEF"/>
+    </module>
+    <module name="JavadocVariableCheck">
+      <property name="scope" value="protected"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="ConstantNameCheck">
+      <property name="format" value="^[A-Z](_?[A-Z0-9]+)*$"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="LocalFinalVariableNameCheck">
+      <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="LocalVariableNameCheck">
+      <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="MemberNameCheck">
+      <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="MethodNameCheck">
+      <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="PackageNameCheck">
+      <property name="format" value="^[a-z]+(\.[a-zA-Z_][a-zA-Z0-9_]*)*$"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="ParameterNameCheck">
+      <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="StaticVariableNameCheck">
+      <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="TypeNameCheck">
+      <property name="format" value="^[A-Z][a-zA-Z0-9]*$"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="CLASS_DEF, INTERFACE_DEF"/>
+    </module>
+    <module name="FileLengthCheck">
+      <property name="max" value="2000"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="LineLengthCheck">
+      <property name="ignorePattern" value="^$"/>
+      <property name="max" value="100"/>
+      <property name="severity" value="warning"/>
+      <property name="tabWidth" value="4"/>
+    </module>
+    <module name="MethodLengthCheck">
+      <property name="max" value="150"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="METHOD_DEF, CTOR_DEF"/>
+    </module>
+    <module name="ParameterNumberCheck">
+      <property name="max" value="7"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="METHOD_DEF, CTOR_DEF"/>
+    </module>
+    <module name="EmptyForIteratorPadCheck">
+      <property name="option" value="nospace"/>
+      <property name="severity" value="warning"/>
+    </module>
+    <module name="NoWhitespaceAfterCheck">
+      <property name="allowLineBreaks" value="true"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="ARRAY_INIT, BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
+    </module>
+    <module name="NoWhitespaceBeforeCheck">
+      <property name="allowLineBreaks" value="true"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="SEMI, POST_DEC, POST_INC"/>
+    </module>
+    <module name="OperatorWrapCheck">
+      <property name="option" value="nl"/>
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, SL, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN"/>
+    </module>
+    <module name="TabCharacterCheck">
+      <property name="severity" value="error"/>
+    </module>
+    <module name="WhitespaceAfterCheck">
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="COMMA, SEMI"/>
+    </module>
+    <module name="WhitespaceAroundCheck">
+      <property name="severity" value="warning"/>
+      <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN"/>
+    </module>
+  </module>
+</module>