
rulesets.java.pmd-level0.xml Maven / Gradle / Ivy
Go to download
Provides a Checkstyle and PMD configuration. The PMD configuration is meant to allow for future hierarchical levels to be defined,
so that projects can choose which level to adhere. Checkstyle is not as flexible. I have provided a check that looks
for a BSD 3 clause header in your project assuming that will be your default, especially in the https://github.com/salesforce/ repositories.
<?xml version="1.0"?> <ruleset name="Custom ruleset" 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>Simple Ruleset</description> <!-- BEGIN: replacement for unusedcode.xml --> <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" /> <!-- END: replacement for unusedcode.xml --> <rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" /> <!-- BEGIN: replacement for rulesets/java/empty.xml --> <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/EmptyInitializer" name="EmptyStaticInitializer" /> <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" /> <!-- loosening for comments as to why it needs to be empty --> <rule ref="category/java/errorprone.xml/EmptyCatchBlock"> <properties> <property name="allowCommentedBlocks" value="true" /> </properties> </rule> <!-- END: replacement for rulesets/java/empty.xml --> <!-- BEGIN: replacement for rulesets/java/imports.xml --> <rule ref="category/java/bestpractices.xml/UnusedImports" /> <rule ref="category/java/errorprone.xml/ImportFromSamePackage" /> <rule ref="category/java/codestyle.xml/DontImportJavaLang" /> <rule ref="category/java/codestyle.xml/DuplicateImports" /> <rule ref="category/java/codestyle.xml/TooManyStaticImports"> <description>Non-test classes may not have more than 4 static imports.</description> <properties> <property name="violationSuppressXPath" value="./TypeDeclaration//MethodDeclaration[../Annotation/MarkerAnnotation/Name[@Image='Test']]" /> </properties> </rule> <rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" /> <!-- END: replacement for rulesets/java/imports.xml --> <!-- BEGIN replacement for rulesets/java/finalizers.xml --> <rule ref="category/java/errorprone.xml/AvoidCallingFinalize" /> <rule ref="category/java/errorprone.xml/EmptyFinalizer" /> <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" /> <!-- END: replacement for rulesets/java/finalizers.xml --> <!-- BEGIN: replacements for strings.xml --> <rule ref="category/java/errorprone.xml/StringBufferInstantiationWithChar" /> <rule ref="category/java/errorprone.xml/UnnecessaryCaseChange" /> <rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings" /> <rule ref="category/java/bestpractices.xml/AvoidStringBufferField" /> <rule ref="category/java/performance.xml/AppendCharacterWithChar" /> <rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse" /> <rule ref="category/java/performance.xml/ConsecutiveLiteralAppends" /> <rule ref="category/java/performance.xml/InefficientEmptyStringCheck" /> <rule ref="category/java/performance.xml/InefficientStringBuffering" /> <rule ref="category/java/performance.xml/InsufficientStringBufferDeclaration" /> <rule ref="category/java/performance.xml/StringInstantiation" /> <rule ref="category/java/performance.xml/StringToString" /> <rule ref="category/java/performance.xml/UseIndexOfChar" /> <rule ref="category/java/performance.xml/UselessStringValueOf" /> <rule ref="category/java/performance.xml/UseStringBufferLength" /> <!-- with loosening for tests --> <rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals"> <description>Non-test classes may not have more than 4 duplicate literals, unless the literal is for an annotation.</description> <properties> <property name="skipAnnotations" value="true" /> <property name="violationSuppressXPath" value="./ancestor::TypeDeclaration//MethodDeclaration[../Annotation/MarkerAnnotation/Name[@Image='Test']]" /> </properties> </rule> <!-- END: replacements for strings.xml --> <!-- BEGIN: replacements for typeresolution.xml --> <rule ref="category/java/bestpractices.xml/LooseCoupling" /> <rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable" /> <rule ref="category/java/bestpractices.xml/UnusedImports" /> <!-- with loosening for tests --> <rule ref="category/java/design.xml/SignatureDeclareThrowsException"> <description>Methods/Constructors in non test classes may not explicitly java.lang.Exception</description> <properties> <!-- doesn't effect parameterized constructors, like maven's --> <!-- property name="IgnoreJUnitCompletely" value="true"/--> <property name="violationSuppressXPath" value="./ancestor::TypeDeclaration//MethodDeclaration[../Annotation/MarkerAnnotation/Name[@Image='Test']]" /> </properties> </rule> <!-- END: replacements for typeresolution.xml --> </ruleset>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy