<?xml version="1.0"?>
<ruleset name="Custom ruleset" xmlns="http://pmd.sf.net/ruleset/1.0.0">
  <description>ROAP project PMD 3.9 rules</description>

  <rule ref="rulesets/basic.xml">
    <exclude name="EmptyCatchBlock"/> <!-- ok in tests but otherwise...? -->
    <exclude name="CollapsibleIfStatements"/>
  </rule>

  <rule ref="rulesets/braces.xml"/>

  <!-- <rule ref="rulesets/codesize.xml"/> -->

  <rule ref="rulesets/clone.xml"/>

  <rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>
  <rule ref="rulesets/controversial.xml/UnusedModifier"/>
  <rule ref="rulesets/controversial.xml/DontImportSun"/>

  <rule ref="rulesets/design.xml">
    <exclude name="UseSingleton"/>
    <exclude name="AvoidReassigningParameters"/>
    <exclude name="FinalFieldCouldBeStatic"/>
    <exclude name="NonStaticInitializer"/>
    <exclude name="ConfusingTernary"/>
    <exclude name="ImmutableField"/>
    <exclude name="AvoidSynchronizedAtMethodLevel"/>
    <exclude name="CompareObjectsWithEquals"/>
    <exclude name="PositionLiteralsFirstInComparisons"/>
    <exclude name="UncommentedEmptyMethod"/>
    <exclude name="UncommentedEmptyConstructor"/>
    <exclude name="AvoidConstantsInterface"/>
    <exclude name="UseCollectionIsEmpty"/>
    <exclude name="AbstractClassWithoutAbstractMethod"/>
    <exclude name="ConstructorCallsOverridableMethod"/>
    <exclude name="UseLocaleWithCaseConversions"/> <!-- while true, this gets annoying -->
    <exclude name="AvoidDeeplyNestedIfStmts"/> <!-- see below -->
  </rule>
  <rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts">
    <properties>
      <property name="problemDepth"><value>5</value></property>
    </properties>
  </rule>

  <rule ref="rulesets/finalizers.xml"/>
  <rule ref="rulesets/imports.xml"/>

  <rule ref="rulesets/junit.xml"/>

  <rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger">
    <properties>
      <!-- allow both 'log' and 'LOG' in XPATH -->
      <property name="xpath">
        <value><![CDATA[
//ClassOrInterfaceBodyDeclaration[FieldDeclaration//ClassOrInterfaceType[@Image='Log']
 and
 not(FieldDeclaration[@Final='true'][@Static='true'][@Private='true'][.//VariableDeclaratorId[@Image='log' or @Image='LOG']]
 //ArgumentList//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration/@Image)
 and
 not(FieldDeclaration[@Final='true'][@Private='true'][.//VariableDeclaratorId[@Image='log']]
 [count(.//VariableInitializer)=0]
 [ancestor::ClassOrInterfaceBody//StatementExpression[.//PrimaryExpression/descendant::*[@Image='log']][count(.//AllocationExpression)=0]]
 )]
        ]]></value>
      </property>
    </properties>
  </rule>
   <!-- <rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/> this should probably be fixed -->

  <rule ref="rulesets/optimizations.xml/UnnecessaryWrapperObjectCreation"/>

  <rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>
  <rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>
  <rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes">
    <properties>
      <!-- removed "Error" case from XPATH -->
      <property name="xpath">
        <value><![CDATA[
//AllocationExpression/ClassOrInterfaceType[@Image='Throwable' or @Image='Exception' or @Image='RuntimeException']
        ]]></value>
      </property>
    </properties>
  </rule>

  <rule ref="rulesets/unusedcode.xml"/>

</ruleset>
