Created
January 26, 2020 10:17
-
-
Save madhur/62e57a851b1dbfbbc3a2646d32dd8897 to your computer and use it in GitHub Desktop.
My PMD Rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" ?> | |
<ruleset name="Custom Rules" 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> | |
Tesseract custom rules | |
</description> | |
<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod" /> | |
<rule ref="category/java/bestpractices.xml/AccessorClassGeneration" /> | |
<rule ref="category/java/bestpractices.xml/AccessorMethodGeneration" /> | |
<rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly" /> | |
<rule ref="category/java/bestpractices.xml/AvoidMessageDigestField" /> | |
<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace" /> | |
<rule ref="category/java/bestpractices.xml/AvoidReassigningLoopVariables" /> | |
<rule ref="category/java/bestpractices.xml/AvoidReassigningParameters" /> | |
<rule ref="category/java/bestpractices.xml/AvoidStringBufferField" /> | |
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" /> | |
<rule ref="category/java/bestpractices.xml/CheckResultSet" /> | |
<rule ref="category/java/bestpractices.xml/ConstantsInInterface" /> | |
<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt" /> | |
<rule ref="category/java/bestpractices.xml/DoubleBraceInitialization" /> | |
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach" /> | |
<rule ref="category/java/bestpractices.xml/ForLoopVariableCount"> | |
<properties> | |
<property name="maximumVariables" value="1" /> | |
</properties> | |
</rule> | |
<!-- Best Practices --> | |
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseAfterAnnotation" /> | |
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseBeforeAnnotation" /> | |
<rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseTestAnnotation" /> | |
<rule ref="category/java/bestpractices.xml/JUnitTestsShouldIncludeAssert" /> | |
<rule ref="category/java/bestpractices.xml/JUnitUseExpected" /> | |
<rule ref="category/java/bestpractices.xml/LooseCoupling" /> | |
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray" /> | |
<rule ref="category/java/bestpractices.xml/MissingOverride" /> | |
<rule ref="category/java/bestpractices.xml/OneDeclarationPerLine" /> | |
<rule ref="category/java/bestpractices.xml/PositionLiteralsFirstInCaseInsensitiveComparisons" /> | |
<rule ref="category/java/bestpractices.xml/PositionLiteralsFirstInComparisons" /> | |
<!-- <rule ref="category/java/bestpractices.xml/PreserveStackTrace" /> --> | |
<rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap" /> | |
<rule ref="category/java/bestpractices.xml/SwitchStmtsShouldHaveDefault" /> | |
<rule ref="category/java/bestpractices.xml/SystemPrintln" /> | |
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /> | |
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable" /> | |
<rule ref="category/java/bestpractices.xml/UnusedPrivateField" /> | |
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" /> | |
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty" /> | |
<rule ref="category/java/bestpractices.xml/UseTryWithResources" /> | |
<rule ref="category/java/bestpractices.xml/WhileLoopWithLiteralBoolean" /> | |
<!-- Code Style --> | |
<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending" /> | |
<rule ref="category/java/codestyle.xml/BooleanGetMethodName" /> | |
<rule ref="category/java/codestyle.xml/ControlStatementBraces"> | |
<properties> | |
<property name="checkIfElseStmt" value="true" /> | |
<property name="checkSingleIfStmt" value="true" /> | |
<property name="checkWhileStmt" value="true" /> | |
<property name="checkForStmt" value="true" /> | |
<property name="checkDoWhileStmt" value="true" /> | |
<property name="checkCaseStmt" value="false" /> | |
<property name="allowEmptyLoop" value="false" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/codestyle.xml/EmptyMethodInAbstractClassShouldBeAbstract" /> | |
<rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass"> | |
<properties> | |
<property name="ignoreEnumDeclarations" value="true" /> | |
<property name="ignoreAnonymousClassDeclarations" value="true" /> | |
<property name="ignoreInterfaceDeclarations" value="false" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches" /> | |
<rule ref="category/java/codestyle.xml/LinguisticNaming"> | |
<properties> | |
<property name="ignoredAnnotations" value="java.lang.Override" /> | |
<property name="checkBooleanMethod" value="true" /> | |
<property name="checkGetters" value="true" /> | |
<property name="checkSetters" value="true" /> | |
<property name="checkPrefixedTransformMethods" value="true" /> | |
<property name="checkTransformMethods" value="false" /> | |
<property name="booleanMethodPrefixes" value="is|has|can|have|will|should" /> | |
<property name="transformMethodNames" value="to|as" /> | |
<property name="checkFields" value="true" /> | |
<property name="checkVariables" value="true" /> | |
<property name="booleanFieldPrefixes" value="is|has|can|have|will|should" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/codestyle.xml/NoPackage" /> | |
<rule ref="category/java/codestyle.xml/ShortClassName"> | |
<properties> | |
<property name="minimum" value="4" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/codestyle.xml/ShortMethodName"> | |
<properties> | |
<property name="minimum" value="3" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/codestyle.xml/ShortVariable"> | |
<properties> | |
<property name="minimum" value="2" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" /> | |
<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn" /> | |
<rule ref="category/java/codestyle.xml/UnnecessaryReturn" /> | |
<rule ref="category/java/codestyle.xml/UseShortArrayInitializer" /> | |
<!-- Design --> | |
<rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod" /> | |
<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts"> | |
<properties> | |
<property name="problemDepth" value="3" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/design.xml/AvoidRethrowingException" /> | |
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException" /> | |
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException" /> | |
<!-- <rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes" /> --> | |
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal" /> | |
<rule ref="category/java/design.xml/CollapsibleIfStatements" /> | |
<rule ref="category/java/design.xml/CouplingBetweenObjects"> | |
<properties> | |
<property name="threshold" value="20" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/design.xml/CyclomaticComplexity"> | |
<properties> | |
<property name="classReportLevel" value="80" /> | |
<property name="methodReportLevel" value="10" /> | |
<property name="cycloOptions" value="" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/design.xml/DoNotExtendJavaLangError" /> | |
<rule ref="category/java/design.xml/ExceptionAsFlowControl" /> | |
<rule ref="category/java/design.xml/ExcessiveParameterList"> | |
<properties> | |
<property name="minimum" value="10.0" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/design.xml/FinalFieldCouldBeStatic" /> | |
<rule ref="category/java/design.xml/GodClass" /> | |
<rule ref="category/java/design.xml/ImmutableField" /> | |
<rule ref="category/java/design.xml/LogicInversion" /> | |
<rule ref="category/java/design.xml/SimplifyBooleanReturns" /> | |
<rule ref="category/java/design.xml/SimplifyConditional" /> | |
<rule ref="category/java/design.xml/SingularField" /> | |
<rule ref="category/java/design.xml/SwitchDensity"> | |
<properties> | |
<property name="minimum" value="10.0" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/design.xml/TooManyFields"> | |
<properties> | |
<property name="maxfields" value="15" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/design.xml/TooManyMethods"> | |
<properties> | |
<property name="maxmethods" value="10" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/design.xml/UselessOverridingMethod" /> | |
<!-- Error prone --> | |
<rule ref="category/java/errorprone.xml/AssignmentInOperand"> | |
<properties> | |
<property name="allowIf" value="false" /> | |
<property name="allowFor" value="false" /> | |
<property name="allowWhile" value="false" /> | |
<property name="allowIncrementDecrement" value="false" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic" /> | |
<rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier" /> | |
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" /> | |
<rule ref="category/java/errorprone.xml/AvoidCallingFinalize" /> | |
<rule ref="category/java/errorprone.xml/AvoidCatchingNPE" /> | |
<rule ref="category/java/errorprone.xml/AvoidCatchingThrowable" /> | |
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" /> | |
<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals"> | |
<properties> | |
<property name="separator" value="," /> | |
<property name="maxDuplicateLiterals" value="4" /> | |
<property name="minimumLength" value="3" /> | |
<property name="skipAnnotations" value="false" /> | |
<property name="exceptionList" value="" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier" /> | |
<rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingMethodName" /> | |
<rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingTypeName" /> | |
<rule ref="category/java/errorprone.xml/AvoidInstanceofChecksInCatchClause" /> | |
<rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition"> | |
<properties> | |
<property name="ignoreMagicNumbers" value="-1,0" /> | |
<!-- <property name="ignoreExpressions" value="true" /> --> | |
</properties> | |
</rule> | |
<rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation" /> | |
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" /> | |
<rule ref="category/java/errorprone.xml/BadComparison" /> | |
<rule ref="category/java/errorprone.xml/BrokenNullCheck" /> | |
<rule ref="category/java/errorprone.xml/CallSuperFirst" /> | |
<rule ref="category/java/errorprone.xml/CheckSkipResult" /> | |
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" /> | |
<rule ref="category/java/errorprone.xml/CloneMethodMustBePublic" /> | |
<rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable" /> | |
<rule ref="category/java/errorprone.xml/CloseResource"> | |
<properties> | |
<property name="closeTargets" value="" /> | |
<property name="types" value="java.lang.AutoCloseable,java.sql.Connection,java.sql.Statement,java.sql.ResultSet" /> | |
<property name="closeAsDefaultTarget" value="true" /> | |
<property name="allowedResourceTypes" value="java.io.ByteArrayOutputStream|java.io.ByteArrayInputStream|java.io.StringWriter|java.io.CharArrayWriter|java.util.stream.Stream" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/errorprone.xml/CompareObjectsWithEquals" /> | |
<rule ref="category/java/errorprone.xml/ConstructorCallsOverridableMethod" /> | |
<rule ref="category/java/errorprone.xml/DoNotCallSystemExit" /> | |
<rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable" /> | |
<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally" /> | |
<rule ref="category/java/errorprone.xml/DontImportSun" /> | |
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" /> | |
<rule ref="category/java/errorprone.xml/EmptyCatchBlock"> | |
<properties> | |
<property name="allowCommentedBlocks" value="false" /> | |
<property name="allowExceptionNameRegex" value="^(ignored|expected)$" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/errorprone.xml/EmptyFinalizer" /> | |
<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/EmptyStatementNotInLoop" /> | |
<rule ref="category/java/errorprone.xml/EmptySwitchStatements" /> | |
<rule ref="category/java/errorprone.xml/EmptySynchronizedBlock" /> | |
<rule ref="category/java/errorprone.xml/EmptyTryBlock" /> | |
<rule ref="category/java/errorprone.xml/EmptyWhileStmt" /> | |
<rule ref="category/java/errorprone.xml/EqualsNull" /> | |
<rule ref="category/java/errorprone.xml/FinalizeDoesNotCallSuperFinalize" /> | |
<rule ref="category/java/errorprone.xml/FinalizeOnlyCallsSuperFinalize" /> | |
<rule ref="category/java/errorprone.xml/FinalizeOverloaded" /> | |
<rule ref="category/java/errorprone.xml/FinalizeShouldBeProtected" /> | |
<rule ref="category/java/errorprone.xml/IdempotentOperations" /> | |
<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/JUnitSpelling" /> | |
<rule ref="category/java/errorprone.xml/JUnitStaticSuite" /> | |
<rule ref="category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass" /> | |
<rule ref="category/java/errorprone.xml/MisplacedNullCheck" /> | |
<rule ref="category/java/errorprone.xml/MissingBreakInSwitch" /> | |
<rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass"> | |
<properties> | |
<property name="annotations" value="org.springframework.beans.factory.annotation.Autowired, javax.inject.Inject" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/errorprone.xml/MoreThanOneLogger" /> | |
<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement" /> | |
<rule ref="category/java/errorprone.xml/NonStaticInitializer" /> | |
<rule ref="category/java/errorprone.xml/NullAssignment" /> | |
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" /> | |
<rule ref="category/java/errorprone.xml/ProperLogger"> | |
<properties> | |
<property name="staticLoggerName" value="LOG" /> | |
<property name="loggerName" value="log" /> | |
<property name="loggerClass" value="Log" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/errorprone.xml/ReturnEmptyArrayRatherThanNull" /> | |
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" /> | |
<rule ref="category/java/errorprone.xml/SimpleDateFormatNeedsLocale" /> | |
<rule ref="category/java/errorprone.xml/SingleMethodSingleton" /> | |
<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance" /> | |
<rule ref="category/java/errorprone.xml/SuspiciousEqualsMethodName" /> | |
<rule ref="category/java/errorprone.xml/SuspiciousHashcodeMethodName" /> | |
<rule ref="category/java/errorprone.xml/TestClassWithoutTestCases" /> | |
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement" /> | |
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange" /> | |
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" /> | |
<rule ref="category/java/errorprone.xml/UseCorrectExceptionLogging" /> | |
<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings" /> | |
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" /> | |
<rule ref="category/java/errorprone.xml/UseProperClassLoader" /> | |
<!-- Multithreading --> | |
<rule ref="category/java/multithreading.xml/DontCallThreadRun" /> | |
<rule ref="category/java/multithreading.xml/UseConcurrentHashMap" /> | |
<!-- Performance --> | |
<rule ref="category/java/performance.xml/AddEmptyString" /> | |
<rule ref="category/java/performance.xml/AppendCharacterWithChar" /> | |
<rule ref="category/java/performance.xml/AvoidArrayLoops" /> | |
<rule ref="category/java/performance.xml/AvoidFileStream" /> | |
<rule ref="category/java/performance.xml/AvoidInstantiatingObjectsInLoops" /> | |
<rule ref="category/java/performance.xml/AvoidUsingShortType" /> | |
<rule ref="category/java/performance.xml/BigIntegerInstantiation" /> | |
<rule ref="category/java/performance.xml/BooleanInstantiation" /> | |
<rule ref="category/java/performance.xml/ByteInstantiation" /> | |
<rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse" /> | |
<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"> | |
<properties> | |
<property name="threshold" value="1" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/performance.xml/InefficientEmptyStringCheck" /> | |
<rule ref="category/java/performance.xml/InefficientStringBuffering" /> | |
<rule ref="category/java/performance.xml/IntegerInstantiation" /> | |
<rule ref="category/java/performance.xml/LongInstantiation" /> | |
<rule ref="category/java/performance.xml/OptimizableToArrayCall" /> | |
<rule ref="category/java/performance.xml/RedundantFieldInitializer" /> | |
<rule ref="category/java/performance.xml/ShortInstantiation" /> | |
<rule ref="category/java/performance.xml/SimplifyStartsWith" /> | |
<rule ref="category/java/performance.xml/StringInstantiation" /> | |
<rule ref="category/java/performance.xml/StringToString" /> | |
<rule ref="category/java/performance.xml/TooFewBranchesForASwitchStatement"> | |
<properties> | |
<property name="minimumNumberCaseForASwitch" value="3" /> | |
</properties> | |
</rule> | |
<rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation" /> | |
<rule ref="category/java/performance.xml/UseArraysAsList" /> | |
<rule ref="category/java/performance.xml/UseIndexOfChar" /> | |
<rule ref="category/java/performance.xml/UselessStringValueOf" /> | |
<rule ref="category/java/performance.xml/UseStringBufferForStringAppends" /> | |
<rule ref="category/java/performance.xml/UseStringBufferLength" /> | |
<!-- Security --> | |
<rule ref="category/java/security.xml/HardCodedCryptoKey" /> | |
<rule ref="category/java/security.xml/InsecureCryptoIv" /> | |
</ruleset> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment