[jsword-svn] jsword-support/tools/pmd s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Tue Aug 16 11:03:06 MST 2005


Update of /cvs/jsword/jsword-support/tools/pmd
In directory www.crosswire.org:/tmp/cvs-serv29457/tools/pmd

Added Files:
	build.xml ruleset.xml HOWTO-UPGRADE.txt 
Log Message:
Upgrading jsword-support/tools

--- NEW FILE: ruleset.xml ---
<?xml version="1.0"?>

<ruleset name="Basic Rules">
  <description>A fairly global ruleset containing almost everything</description>

  <!-- <rule ref="rulesets/basic.xml/EmptyCatchBlock"/> done better by checkstyle -->
  <!-- <rule ref="rulesets/basic.xml/EmptyIfStmt"/> done better by checkstyle -->
  <rule ref="rulesets/basic.xml/EmptyWhileStmt"/>
  <rule ref="rulesets/basic.xml/EmptyTryBlock"/>
  <rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>
  <rule ref="rulesets/basic.xml/EmptySwitchStatements"/>
  <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
  <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
  <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
  <rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>
  <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
  <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
  <rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>
  <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
  <rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>
  <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
  <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
  <rule ref="rulesets/basic.xml/BooleanInstantiation"/>

  <!-- <rule ref="rulesets/naming.xml/ShortVariable"/> 687 reports -->
  <!-- <rule ref="rulesets/naming.xml/LongVariable"/> 668 reports -->
  <rule ref="rulesets/naming.xml/ShortMethodName"/>
  <!-- <rule ref="rulesets/naming.xml/VariableNamingConventions"/> 159 reports -->
  <rule ref="rulesets/naming.xml/MethodNamingConventions"/>
  <rule ref="rulesets/naming.xml/ClassNamingConventions"/>
  <!-- <rule ref="rulesets/naming.xml/AbstractNaming"/> Reports on JSword enumerations -->
  <rule ref="rulesets/naming.xml/AvoidDollarSigns"/>
  <rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>
  <rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>
  <rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>
  <rule ref="rulesets/naming.xml/SuspiciousEqualsMethodName"/>

  <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
  <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
  <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/> Buggy -->
  <rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>

  <rule ref="rulesets/design.xml/UseSingleton"/>
  <rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
  <rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
  <rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>
  <!-- <rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/> 6 reports -->
  <!-- <rule ref="rulesets/design.xml/AvoidReassigningParameters"/> 33 infringements, but silly fixing -->
  <rule ref="rulesets/design.xml/SwitchDensity"/>
  <!-- <rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/> 41 infringements, might be worth working through -->
  <rule ref="rulesets/design.xml/AccessorClassGeneration"/>
  <rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>
  <rule ref="rulesets/design.xml/CloseConnection"/>
  <rule ref="rulesets/design.xml/NonStaticInitializer"/>
  <rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>
  <rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>
  <rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
  <rule ref="rulesets/design.xml/BadComparison"/>
  <rule ref="rulesets/design.xml/EqualsNull"/>
  <!-- <rule ref="rulesets/design.xml/ConfusingTernary"/> allow (test ? 1 : 2) -->
  <rule ref="rulesets/design.xml/InstantiationToGetClass"/>
  <rule ref="rulesets/design.xml/IdempotentOperations"/>
  <rule ref="rulesets/design.xml/SimpleDateFormatNeedsLocale"/>
  <!-- <rule ref="rulesets/design.xml/ImmutableField"/> 257 reports. -->
  <rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>
  <rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
  <rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>

  <rule ref="rulesets/imports.xml/DuplicateImports"/>
  <rule ref="rulesets/imports.xml/DontImportJavaLang"/>
  <rule ref="rulesets/imports.xml/UnusedImports"/>
  <rule ref="rulesets/imports.xml/ImportFromSamePackage"/>

  <!-- however *test is exempt from coding conventions so these are not run
  <rule ref="rulesets/junit.xml/JUnitStaticSuite"/>
  <rule ref="rulesets/junit.xml/JUnitSpelling"/>
  <rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>
  <rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>
-->

  <!-- <rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/> 2 reports, but silly fixing -->
  <!-- <rule ref="rulesets/strings.xml/StringInstantiation"/> 5 reports. PasswordField new String(getPassword()) -->
  <rule ref="rulesets/strings.xml/StringToString"/>
  <rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>

  <rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>
  <rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>
  <rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>
  <rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>

  <!-- <rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/> 8 reports. -->
  <rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>
  <!-- <rule ref="rulesets/codesize.xml/ExcessiveClassLength"/> 3 reports. -->
  <!-- <rule ref="rulesets/codesize.xml/CyclomaticComplexity"/> 40 reports, maybe check comments? -->
  <rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>

  <!-- <rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/> 652 reports. -->
  <rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>
  <rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>
  <rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>
  <rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>
  <rule ref="rulesets/finalizers.xml/ExplicitCallToFinalize"/>
  <rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>

  <rule ref="rulesets/clone.xml/ProperCloneImplementation"/>
  <!-- try me <rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/> -->
  <!-- try me <rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/> -->

  <!-- <rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/> 13 reports, but silly fixing-->
  <!-- <rule ref="rulesets/coupling.xml/ExcessiveImports"/> 12 reports. -->
  <rule ref="rulesets/coupling.xml/LooseCoupling"/>

  <rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>
  <!-- <rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/> 3 reports. -->
  <rule ref="rulesets/strictexception.xml/ExceptionTypeChecking"/>
  <rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>
  <!-- <rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/> 4 reports. -->
  <!-- <rule ref="rulesets/strictexception.xml/AvoidThrowingCertainExceptionTypes"/> 10 reports -->

  <!-- <rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/> Not written very well. -->
  <!-- <rule ref="rulesets/controversial.xml/NullAssignment"/> 68 reports -->
  <!-- <rule ref="rulesets/controversial.xml/OnlyOneReturn"/> 558 reports -->
  <!-- <rule ref="rulesets/controversial.xml/UnusedModifier"/> 197 reports -->
  <rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
  <!-- <rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/> 149 reports -->
  <rule ref="rulesets/controversial.xml/DontImportSun"/>
  <rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>

  <!-- <rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/> Not written very well. -->
  <!-- <rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/> Not very smart. -->
  <!-- <rule ref="rulesets/logging-java.xml/SystemPrintln"/> 17 reports in APIExamples. But, way too slow. 5+ minutes.-->
  
  <!-- <rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/> 2171 reports! -->
  <!-- <rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/> 2359 reports! -->
  <!-- <rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/> 88 reports. -->
  
</ruleset>

--- NEW FILE: build.xml ---
<project name="pmd" default="pmd">

  <!-- this should be overridden by the parent file -->
  <property name="support.tools" value=".."/>

  <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
	<classpath>
	  <fileset dir="${support.tools}/pmd" includes="**/*.jar"/>
	</classpath>
  </taskdef>

  <target name="pmd">
    <mkdir dir="${target.web}/pmd"/>
    <pmd rulesetfiles="${basedir}/${support.tools}/pmd/ruleset.xml" shortFilenames="true">
      <formatter type="html" toFile="${target.web}/pmd/index.html"/>
      <fileset dir="..">
        <patternset refid="pattern.alljava"/>
      </fileset>
    </pmd>
  </target>

  <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask">
	<classpath>
	  <fileset dir="${support.tools}/pmd" includes="**/*.jar"/>
	</classpath>
  </taskdef>

  <target name="cpd">
    <mkdir dir="${target.web}/cpd"/>
    <cpd minimumTokenCount="100" outputFile="${target.web}/cpd/report.txt">
      <fileset dir="..">
        <patternset refid="pattern.alljava"/>
      </fileset>
    </cpd>
  </target>

</project>

--- NEW FILE: HOWTO-UPGRADE.txt ---
Instructions on how to upgrade pmd.
Obtain the most recent version of pmd from
   http://sourceforge.net/projects/pmd

Unzip the file into this directory.
In the new directory, remove the following:
   bin
   docs

In CVS remove the old pmd directory.

Determine what has changed in pmd and update ruleset.xml appropriately.




More information about the jsword-svn mailing list