<?xml version="1.0"?>
<!--
 Copyright (c) 2020, Adam <Adam@sigterm.info>
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:

 1. Redistributions of source code must retain the above copyright notice, this
    list of conditions and the following disclaimer.
 2. Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions and the following disclaimer in the documentation
    and/or other materials provided with the distribution.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<ruleset name="RuneLite"
		 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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">

	<description>
		RuneLite PMD ruleset
	</description>

	<!-- best practices -->
	<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace"/>
	<rule ref="category/java/bestpractices.xml/DoubleBraceInitialization"/>
	<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach"/>
	<rule ref="category/java/bestpractices.xml/MissingOverride"/>
	<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>
	<rule ref="category/java/bestpractices.xml/SystemPrintln"/>
	<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
	<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
	<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
		<properties>
			<property name="ignoredAnnotations"
					  value="net.runelite.client.eventbus.Subscribe|com.google.inject.Provides"/>
		</properties>
	</rule>
	<rule ref="category/java/bestpractices.xml/UseTryWithResources"/>
	<rule ref="category/java/bestpractices.xml/WhileLoopWithLiteralBoolean"/>

	<!-- code style -->
	<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/>
	<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/>
	<rule ref="category/java/codestyle.xml/DontImportJavaLang"/>
	<rule ref="category/java/codestyle.xml/ExtendsObject"/>
	<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
	<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
	<rule ref="category/java/codestyle.xml/PackageCase"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryCast"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
	<rule ref="category/java/codestyle.xml/UnnecessaryModifier"/>
	<rule ref="category/java/codestyle.xml/UseDiamondOperator"/>
	<rule ref="category/java/codestyle.xml/UseShortArrayInitializer"/>

	<!-- design -->
	<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"/>
	<rule ref="category/java/design.xml/FinalFieldCouldBeStatic"/>
	<rule ref="category/java/design.xml/ImmutableField"/>
	<rule ref="category/java/design.xml/SimplifyBooleanExpressions"/>
	<rule ref="category/java/design.xml/SimplifyConditional"/>
	<rule ref="category/java/design.xml/UselessOverridingMethod"/>

	<!-- error prone -->
	<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
	<rule ref="category/java/errorprone.xml/DontImportSun"/>
	<rule ref="category/java/errorprone.xml/EmptyFinallyBlock"/>
	<rule ref="category/java/errorprone.xml/EmptyIfStmt"/>
	<rule ref="category/java/errorprone.xml/EmptyInitializer"/>
	<rule ref="category/java/errorprone.xml/EmptyStatementBlock"/>
	<rule ref="category/java/errorprone.xml/ImportFromSamePackage"/>
	<rule ref="category/java/errorprone.xml/InstantiationToGetClass"/>
	<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/>
	<rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
	<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
	<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
	<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
	<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/>

	<!-- performance -->
	<rule ref="category/java/performance.xml/AppendCharacterWithChar"/>
	<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/>
	<rule ref="category/java/performance.xml/InefficientStringBuffering"/>
	<rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation"/>
</ruleset>
