<?xml version="1.0"?>
<ruleset name="dogfood" 
	xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
	<description>Rules to check PMD itself.  This RuleSet is written to include all Rules,
	and exclude those which we know are explicitly decided as not applicable to PMD itself.
	This is the most encompassing form of RuleSet.</description>

    <!-- Exclude JavaCC generated artifacts -->
	<exclude-pattern>.*net/sourceforge/pmd/lang/ast/JavaCharStream.java</exclude-pattern>
	<exclude-pattern>.*net/sourceforge/pmd/lang/ast/SimpleCharStream.java</exclude-pattern>
	<exclude-pattern>.*net/sourceforge/pmd/lang/ast/TokenMgrError.java</exclude-pattern>
	<exclude-pattern>.*lang/(java|jsp|cpp)/ast/.*Parser.java</exclude-pattern>
	<exclude-pattern>.*lang/(java|jsp|cpp)/ast/.*ParserConstants.java</exclude-pattern>
	<exclude-pattern>.*lang/(java|jsp|cpp)/ast/.*ParserTokenManager.java</exclude-pattern>
	<exclude-pattern>.*lang/(java|jsp|cpp)/ast/.*ParserTreeConstants.java</exclude-pattern>
	<exclude-pattern>.*lang/(java|jsp|cpp)/ast/.*ParserVisitor.java</exclude-pattern>
	<exclude-pattern>.*lang/(java|jsp|cpp)/ast/JJT.*ParserState.java</exclude-pattern>
	<exclude-pattern>.*lang/(java|jsp|cpp)/ast/ParseException.java</exclude-pattern>
	<exclude-pattern>.*lang/(java|jsp|cpp)/ast/Token.java</exclude-pattern>

	<!-- TODO First step is to re-enable these Rules from the original dogfood, as these are subjectively most important:
	   UnusedPrivateField
	   AvoidCatchingThrowable
	   EmptyCatchBlock
	-->

	<rule ref="rulesets/internal/pmdspecific.xml"/>

	<rule ref="rulesets/java/basic.xml">
    	<exclude name="CollapsibleIfStatements"/>
	</rule>

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

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

	<!-- Nothing here applies to PMD
	<rule ref="rulesets/java/codesize.xml"/>
	</rule>
	-->
	
	<rule ref="rulesets/java/controversial.xml">
		<exclude name="AvoidLiteralsInIfCondition"/>
		<exclude name="OnlyOneReturn"/>
		<exclude name="AtLeastOneConstructor"/>
		<exclude name="CallSuperInConstructor"/>
		<exclude name="DefaultPackage"/>
		<exclude name="DataflowAnomalyAnalysis"/>
		<exclude name="AvoidFinalLocalVariable"/>
		<exclude name="DataflowAnomalyAnalysis"/>
		<exclude name="AssignmentInOperand"/>
		<exclude name="NullAssignment"/>
		<exclude name="UseObjectForClearerAPI"/>
		<exclude name="UseConcurrentHashMap"/>
        </rule>
	<rule ref="rulesets/java/controversial.xml/AssignmentInOperand">
		<properties>
			<property name="allowWhile" value="true"/>
		</properties>
	</rule>

	<rule ref="rulesets/java/coupling.xml">
		<exclude name="CouplingBetweenObjects"/>
		<exclude name="ExcessiveImports"/>
        <exclude name="LawOfDemeter"/>
        <exclude name="LoosePackageCoupling"/>
	</rule>

	<rule ref="rulesets/java/design.xml">
		<exclude name="UseUtilityClass"/>
		<exclude name="AvoidDeeplyNestedIfStmts"/>
		<exclude name="AvoidReassigningParameters"/>
		<exclude name="SwitchDensity"/>
		<exclude name="ConstructorCallsOverridableMethod"/>
		<exclude name="SimpleDateFormatNeedsLocale"/>
		<exclude name="ImmutableField"/>
		<exclude name="UseLocaleWithCaseConversions"/>
		<!--  TODO Is AvoidSynchronizedAtMethodLevel something we should shoot for? -->
		<exclude name="AvoidSynchronizedAtMethodLevel"/>
		<exclude name="EmptyMethodInAbstractClassShouldBeAbstract"/>
		<exclude name="ReturnEmptyArrayRatherThanNull"/>
		<exclude name="TooFewBranchesForASwitchStatement"/>
		<exclude name="ConfusingTernary"/>
		<!-- TODO Work towards enabling the following, disabled for now because of failing code -->
		<exclude name="PositionLiteralsFirstInComparisons"/>
		<exclude name="PreserveStackTrace"/>
		<exclude name="UncommentedEmptyConstructor"/>
		<exclude name="UncommentedEmptyMethodBody"/>
		<exclude name="UnnecessaryLocalBeforeReturn"/>
		<exclude name="AbstractClassWithoutAbstractMethod"/>
		<exclude name="AccessorClassGeneration"/>
		<exclude name="SimplifyBooleanExpressions"/>
		<exclude name="UseVarargs"/>
		<exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
	</rule>

	<rule ref="rulesets/java/empty.xml">
		<exclude name="EmptyCatchBlock" />
		<!-- TODO Work towards enabling the following, disabled for now because of failing code -->
		<exclude name="EmptyIfStmt" />
	</rule>
	<!-- TODO Work towards enabling the following, disabled for now because of failing code -->
	<!--
	<rule ref="rulesets/java/empty.xml/EmptyCatchBlock">
		<properties>
			<property name="allowCommentedBlocks" value="true" />
		</properties>
	</rule>
	-->

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

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

	<!-- Nothing here applies to PMD
	<rule ref="rulesets/java/j2ee.xml"/>
	</rule>
	-->

	<!-- Nothing here applies to PMD
	<rule ref="rulesets/java/javabeans.xml"/>
	</rule>
	-->

	<!-- Nothing here applies to PMD
	<rule ref="rulesets/java/junit.xml"/>
	</rule>
	-->

	<!-- Nothing here applies to PMD
	<rule ref="rulesets/java/logging-jakarta-commons.xml"/>
	</rule>
	-->

	<rule ref="rulesets/java/logging-java.xml">
		<!-- TODO Work towards enabling the following, disabled for now because of failing code -->
		<exclude name="SystemPrintln"/>
		<exclude name="AvoidPrintStackTrace"/>
	</rule>

	<!-- Specifically reference via other referencing RuleSets to test Reference to Reference -->
	<rule ref="rulesets/java/migrating_to_13.xml"/>
	<rule ref="rulesets/java/migrating_to_14.xml"/>
	<rule ref="rulesets/java/migrating_to_15.xml"/>

	<rule ref="rulesets/java/naming.xml">
		<exclude name="ShortVariable"/>
		<exclude name="LongVariable"/>
		<exclude name="ShortMethodName"/>
		<exclude name="ShortClassName"/>
		<!-- TODO Work towards enabling the following, disabled for now because of failing code -->
		<exclude name="AvoidFieldNameMatchingMethodName"/>
		<exclude name="AbstractNaming"/>
		<exclude name="MethodNamingConventions"/>
		<exclude name="AvoidFieldNameMatchingTypeName"/>
		<exclude name="BooleanGetMethodName"/>
	</rule>

	<rule ref="rulesets/java/optimizations.xml">
		<exclude name="MethodArgumentCouldBeFinal"/>
		<exclude name="LocalVariableCouldBeFinal"/>
		<!-- TODO Work towards enabling the following, disabled for now because of failing code -->
		<exclude name="AvoidInstantiatingObjectsInLoops"/>
		<exclude name="RedundantFieldInitializer"/>
		<exclude name="UseStringBufferForStringAppends"/>
	</rule>

	<rule ref="rulesets/java/strictexception.xml">
		<!-- TODO Work towards enabling the following, disabled for now because of failing code -->
		<exclude name="AvoidCatchingGenericException"/>
		<exclude name="AvoidThrowingRawExceptionTypes"/>
		<exclude name="SignatureDeclareThrowsException"/>
		<exclude name="DoNotThrowExceptionInFinally"/>
		<exclude name="AvoidCatchingThrowable"/>
	</rule>

	<rule ref="rulesets/java/strings.xml">
		<exclude name="AvoidDuplicateLiterals"/>
		<exclude name="InefficientEmptyStringCheck"/>
		<!-- TODO Work towards enabling the following, disabled for now because of failing code -->
		<exclude name="ConsecutiveLiteralAppends"/>
		<exclude name="InefficientStringBuffering"/>
	</rule>

	<!-- TODO should we apply these? -->
	<!--
	<rule ref="rulesets/java/sunsecure.xml"/>
	-->
    
	<rule ref="rulesets/java/unnecessary.xml"/>

	<rule ref="rulesets/java/unusedcode.xml">
		<exclude name="UnusedFormalParameter"/>
		<!-- TODO Work towards enabling the following, disabled for now because of failing code -->
		<exclude name="UnusedPrivateField"/>
	</rule>
    
	<!-- Don't let the Language specific APIs leak out -->
	<!--
	<rule name="LanguageLoosePackageCoupling" ref="rulesets/java/coupling.xml/LoosePackageCoupling">
		<properties>
			<property name="packages"><value>net.sourceforge.pmd.lang,net.sourceforge.pmd.lang.java,net.sourceforge.pmd.lang.jsp,net.sourceforge.pmd.lang.ecmascript,net.sourceforge.pmd.lang.cpp</value></property>
			<property name="classes">
				<value>net.sourceforge.pmd.lang.Language,net.sourceforge.pmd.lang.LanguageVersion,net.sourceforge.pmd.lang.LanguageVersionDiscoverer,net.sourceforge.pmd.lang.LanguageVersionHandler,net.sourceforge.pmd.lang.Parser,net.sourceforge.pmd.lang.ast.Node</value>
			</property>
		</properties>
	</rule>
	-->

</ruleset>
