All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
nity4j.sanity4j.1.8.1.source-code.sanity4j_pmd_rules.xml Maven / Gradle / Ivy
<?xml version="1.0"?>
<ruleset
name ="Sanity4J Development Rules"
xsi:schemaLocation ="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation ="http://pmd.sf.net/ruleset_xml_schema.xsd"
xmlns ="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance">
<description>
This is the Sanity4J rule set, which adds to the in-built PMD rules,
with customised priorities. Where there is overlap with another tool
(FindBugs, Checkstyle etc.), the other tool is usually used in
preference to PMD.
</description>
<rule
name ="IncorrectlyLoggedException"
since ="4.2.2"
message ="Incorrectly logged exception"
class ="net.sourceforge.pmd.lang.rule.XPathRule"
language ="java"
externalInfoUrl ="">
<description>
Do not rely on an Exception's toString() representation when logging
errors, as it may not contain enough information (e.g. the
Stacktrace). Use the log.error(String, Throwable) method instead.
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//CatchStatement/Block/BlockStatement/Statement[
ends-with(StatementExpression/PrimaryExpression/PrimaryPrefix/Name/@Image, '.error')
][
StatementExpression/PrimaryExpression/PrimarySuffix/Arguments/ArgumentList/Expression/AdditiveExpression/PrimaryExpression/PrimaryPrefix/Name/@Image = ../../../FormalParameter/VariableDeclaratorId/@Image
]
]]>
</value>
</property>
</properties>
<example>
<![CDATA[
public class MyClass
{
private static final Logger log = Logger.get(MyClass.class);
public byte[] getData()
{
try
{
return StreamUtils.read(new FileInputStream("data"));
}
catch (IOException e)
{
//log.error("Bad" + e);
//log.error("Ok" + e.getMessage());
log.error("Better", e);
}
}
}
]]>
</example>
</rule>
<!-- *************************************************************************
In-built PMD rules, with customised priorities. Where there is overlap with
another tool (FindBugs, Checkstyle etc.), the other tool is usually used in
preference to PMD.
************************************************************************** -->
<!-- Android rules -->
<!-- Unused (we don't use Android)
<rule ref="rulesets/java/android.xml/CallSuperFirst"><priority>5</priority></rule>
<rule ref="rulesets/java/android.xml/CallSuperLast"><priority>5</priority></rule>
<rule ref="rulesets/java/android.xml/DoNotHardCodeSDCard"><priority>5</priority></rule>
-->
<!-- Basic JSF rules -->
<!-- Unused (we don't use JSF)
<rule ref="rulesets/java/basic-jsf.xml/DontNestJsfInJstlIteration"><priority>#</priority></rule>
-->
<!-- Basic JSP rules -->
<!-- Unused (fail when accidentally run against java source)
<rule ref="rulesets/java/basic-jsp.xml/NoLongScripts"><priority>4</priority></rule>
<rule ref="rulesets/java/basic-jsp.xml/NoScriptlets"><priority>4</priority></rule>
<rule ref="rulesets/java/basic-jsp.xml/NoInlineStyleInformation"><priority>4</priority></rule>
<rule ref="rulesets/java/basic-jsp.xml/NoClassAttribute"><priority>4</priority></rule>
<rule ref="rulesets/java/basic-jsp.xml/NoJspForward"><priority>4</priority></rule>
<rule ref="rulesets/java/basic-jsp.xml/IframeMissingSrcAttribute"><priority>4</priority></rule>
<rule ref="rulesets/java/basic-jsp.xml/NoHtmlComments"><priority>4</priority></rule>
<rule ref="rulesets/java/basic-jsp.xml/DuplicateJspImports"><priority>4</priority></rule>
<rule ref="rulesets/java/basic-jsp.xml/JspEncoding"><priority>4</priority></rule>
-->
<!-- Basic Rules -->
<rule ref="rulesets/java/basic.xml/AvoidBranchingStatementAsLastInLoop"><priority>3</priority></rule>
<rule ref="rulesets/java/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor"><priority>3</priority></rule>
<rule ref="rulesets/java/basic.xml/AvoidMultipleUnaryOperators"><priority>2</priority></rule>
<rule ref="rulesets/java/basic.xml/AvoidThreadGroup"><priority>3</priority></rule>
<rule ref="rulesets/java/basic.xml/AvoidUsingOctalValues"><priority>3</priority></rule>
<rule ref="rulesets/java/basic.xml/AvoidUsingHardCodedIP"><priority>2</priority></rule>
<rule ref="rulesets/java/basic.xml/BigIntegerInstantiation"><priority>3</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/basic.xml/BooleanInstantiation"><priority>3</priority></rule>
-->
<rule ref="rulesets/java/basic.xml/BrokenNullCheck"><priority>2</priority></rule>
<rule ref="rulesets/java/basic.xml/CheckResultSet"><priority>2</priority></rule>
<rule ref="rulesets/java/basic.xml/CheckSkipResult"><priority>3</priority></rule>
<rule ref="rulesets/java/basic.xml/ClassCastExceptionWithToArray"><priority>2</priority></rule>
<rule ref="rulesets/java/basic.xml/CollapsibleIfStatements"><priority>4</priority></rule>
<rule ref="rulesets/java/basic.xml/DontCallThreadRun"><priority>3</priority></rule>
<rule ref="rulesets/java/basic.xml/DontUseFloatTypeForLoopIndices"><priority>4</priority></rule>
<rule ref="rulesets/java/basic.xml/DoubleCheckedLocking"><priority>3</priority></rule>
<rule ref="rulesets/java/basic.xml/ExtendsObject"><priority>4</priority></rule>
<rule ref="rulesets/java/basic.xml/ForLoopShouldBeWhileLoop"><priority>4</priority></rule>
<rule ref="rulesets/java/basic.xml/JumbledIncrementer"><priority>3</priority></rule>
<rule ref="rulesets/java/basic.xml/OverrideBothEqualsAndHashcode"><priority>4</priority></rule>
<rule ref="rulesets/java/basic.xml/UnconditionalIfStatement"><priority>2</priority></rule>
<rule ref="rulesets/java/basic.xml/MisplacedNullCheck"><priority>2</priority></rule>
<rule ref="rulesets/java/basic.xml/ReturnFromFinallyBlock"><priority>3</priority></rule>
<rule ref="rulesets/java/basic.xml/SimplifiedTernary"><priority>4</priority></rule>
<!-- Braces Rules -->
<!-- Using Checkstyle for these
<rule ref="rulesets/java/braces.xml/IfStmtsMustUseBraces"><priority>4</priority></rule>
<rule ref="rulesets/java/braces.xml/WhileLoopsMustUseBraces"><priority>4</priority></rule>
<rule ref="rulesets/java/braces.xml/IfElseStmtsMustUseBraces"><priority>4</priority></rule>
<rule ref="rulesets/java/braces.xml/ForLoopsMustUseBraces"><priority>4</priority></rule>
-->
<!-- Clone Implementation Rules -->
<!-- Using Findbugs rule
<rule ref="rulesets/java/clone.xml/ProperCloneImplementation"><priority>2</priority></rule>
-->
<rule ref="rulesets/java/clone.xml/CloneMethodMustBePublic"><priority>3</priority></rule>
<rule ref="rulesets/java/clone.xml/CloneMethodReturnTypeMustMatchClassName"><priority>3</priority></rule>
<rule ref="rulesets/java/clone.xml/CloneThrowsCloneNotSupportedException"><priority>3</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/clone.xml/CloneMethodMustImplementCloneable"><priority>3</priority></rule>
-->
<!-- Code Size Rules -->
<rule ref="rulesets/java/codesize.xml/NPathComplexity"><priority>5</priority></rule>
<rule ref="rulesets/java/codesize.xml/ExcessiveMethodLength"><priority>5</priority></rule>
<rule ref="rulesets/java/codesize.xml/ExcessiveParameterList"><priority>5</priority></rule>
<rule ref="rulesets/java/codesize.xml/ExcessiveClassLength"><priority>5</priority></rule>
<rule ref="rulesets/java/codesize.xml/CyclomaticComplexity"><priority>4</priority></rule>
<rule ref="rulesets/java/codesize.xml/ExcessivePublicCount"><priority>5</priority></rule>
<rule ref="rulesets/java/codesize.xml/TooManyFields"><priority>5</priority></rule>
<rule ref="rulesets/java/codesize.xml/NcssMethodCount"><priority>5</priority></rule>
<rule ref="rulesets/java/codesize.xml/NcssTypeCount"><priority>5</priority></rule>
<rule ref="rulesets/java/codesize.xml/NcssConstructorCount"><priority>5</priority></rule>
<!-- Handled by Checkstyle
<rule ref="rulesets/java/codesize.xml/StdCyclomaticComplexity"><priority>5</priority></rule>
<rule ref="rulesets/java/codesize.xml/ModifiedCyclomaticComplexity"><priority>5</priority></rule>
-->
<rule ref="rulesets/java/codesize.xml/TooManyMethods">
<priority>5</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//ClassOrInterfaceDeclaration/ClassOrInterfaceBody[
count(
descendant::MethodDeclarator[
not(
starts-with(@Image,'get')
or
starts-with(@Image,'set')
)
]
) > $maxmethods
][
not(
../ExtendsList/ClassOrInterfaceType[typeof(@Image, 'junit.framework.TestCase','TestCase')
or
//MarkerAnnotation/Name[typeof(@Image, 'org.junit.Test', 'Test')]]
)
]
]]>
</value>
</property>
</properties>
</rule>
<!-- Comments Rules -->
<!-- Using Checkstyle for these
<rule ref="rulesets/java/comments.xml/CommentContent"><priority>5</priority></rule>
<rule ref="rulesets/java/comments.xml/CommentDefaultAccessModifier"><priority>5</priority></rule>
<rule ref="rulesets/java/comments.xml/CommentRequired"><priority>5</priority></rule>
<rule ref="rulesets/java/comments.xml/CommentSize"><priority>5</priority></rule>
-->
<!-- Controversial Rules -->
<rule ref="rulesets/java/controversial.xml/AvoidLiteralsInIfCondition"><priority>5</priority></rule>
<rule ref="rulesets/java/controversial.xml/OneDeclarationPerLine"><priority>4</priority></rule>
<rule ref="rulesets/java/controversial.xml/UnnecessaryConstructor"><priority>3</priority></rule>
<rule ref="rulesets/java/controversial.xml/AssignmentInOperand"><priority>3</priority></rule>
<rule ref="rulesets/java/controversial.xml/DontImportSun"><priority>4</priority></rule>
<rule ref="rulesets/java/controversial.xml/DefaultPackage"><priority>3</priority></rule>
<rule ref="rulesets/java/controversial.xml/AvoidUsingVolatile"><priority>3</priority></rule>
<rule ref="rulesets/java/controversial.xml/AvoidUsingNativeCode"><priority>4</priority></rule>
<rule ref="rulesets/java/controversial.xml/AvoidAccessibilityAlteration"><priority>4</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/controversial.xml/DoNotCallGarbageCollectionExplicitly"><priority>4</priority></rule>
-->
<!-- unused
<rule ref="rulesets/java/controversial.xml/AvoidPrefixingMethodParameters"><priority>5</priority></rule>
<rule ref="rulesets/java/controversial.xml/NullAssignment"><priority>#</priority></rule>
<rule ref="rulesets/java/controversial.xml/OnlyOneReturn"><priority>#</priority></rule>
<rule ref="rulesets/java/controversial.xml/UseConcurrentHashMap"><priority>5</priority></rule>
<rule ref="rulesets/java/controversial.xml/UseObjectForClearerAPI"><priority>5</priority></rule>
<rule ref="rulesets/java/controversial.xml/AtLeastOneConstructor"><priority>#</priority></rule>
<rule ref="rulesets/java/controversial.xml/SuspiciousOctalEscape"><priority>#</priority></rule>
<rule ref="rulesets/java/controversial.xml/CallSuperInConstructor"><priority>#</priority></rule>
<rule ref="rulesets/java/controversial.xml/UnnecessaryParentheses"><priority>#</priority></rule>
<rule ref="rulesets/java/controversial.xml/BooleanInversion"><priority>#</priority></rule>
<rule ref="rulesets/java/controversial.xml/DataflowAnomalyAnalysis"><priority>#</priority></rule>
<rule ref="rulesets/java/controversial.xml/AvoidFinalLocalVariable"><priority>#</priority></rule>
<rule ref="rulesets/java/controversial.xml/AvoidUsingShortType"><priority>#</priority></rule>
-->
<!-- Coupling Rules -->
<rule ref="rulesets/java/coupling.xml/CouplingBetweenObjects"><priority>5</priority></rule>
<rule ref="rulesets/java/coupling.xml/ExcessiveImports"><priority>5</priority></rule>
<rule ref="rulesets/java/coupling.xml/LooseCoupling"><priority>5</priority></rule>
<!-- Causes too many issues with other APIs
<rule ref="rulesets/java/coupling.xml/LawOfDemeter"><priority>5</priority></rule>
<rule ref="rulesets/java/coupling.xml/LoosePackageCoupling"><priority>5</priority></rule>
-->
<!-- Design Rules -->
<rule ref="rulesets/java/design.xml/AccessorMethodGeneration"><priority>5</priority></rule>
<!-- Leaving package-protected triggers a different check
<rule ref="rulesets/java/design.xml/AvoidProtectedMethodInFinalClassNotExtending"><priority>5</priority></rule>
-->
<!-- unused
<rule ref="rulesets/java/design.xml/UseUtilityClass"><priority>#</priority></rule>
-->
<rule ref="rulesets/java/design.xml/FieldDeclarationsShouldBeAtStartOfClass"><priority>5</priority></rule>
<rule ref="rulesets/java/design.xml/GodClass"><priority>4</priority></rule>
<rule ref="rulesets/java/design.xml/LogicInversion"><priority>4</priority></rule>
<rule ref="rulesets/java/design.xml/PositionLiteralsFirstInCaseInsensitiveComparisons"><priority>3</priority></rule>
<!--
<rule ref="rulesets/java/design.xml/SingleMethodSingleton"><priority>4</priority></rule>
<rule ref="rulesets/java/design.xml/SingletonClassReturningNewInstance"><priority>4</priority></rule>
-->
<rule ref="rulesets/java/design.xml/UseVarargs"><priority>5</priority></rule>
<rule ref="rulesets/java/design.xml/SimplifyBooleanReturns"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/SimplifyBooleanExpressions"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/SwitchStmtsShouldHaveDefault"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/AvoidDeeplyNestedIfStmts"><priority>5</priority></rule>
<rule ref="rulesets/java/design.xml/AvoidReassigningParameters"><priority>4</priority></rule>
<rule ref="rulesets/java/design.xml/SwitchDensity"><priority>5</priority></rule>
<rule ref="rulesets/java/design.xml/ConstructorCallsOverridableMethod"><priority>4</priority></rule>
<rule ref="rulesets/java/design.xml/AccessorClassGeneration"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/FinalFieldCouldBeStatic"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/CloseResource"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/NonStaticInitializer">
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//Initializer[
@Static='false'
][
not(
../../../ClassOrInterfaceType[
@Image='Expectations'
][
/ImportDeclaration/Name/@Image='org.jmock.Expectations'
]
or
../../../ClassOrInterfaceType[
@Image='Mockery'
][
/ImportDeclaration/Name/@Image='org.jmock.Mockery'
]
)
]
]]>
</value>
</property>
</properties>
</rule>
<rule ref="rulesets/java/design.xml/DefaultLabelNotLastInSwitchStmt"><priority>2</priority></rule>
<rule ref="rulesets/java/design.xml/NonCaseLabelInSwitchStatement"><priority>2</priority></rule>
<rule ref="rulesets/java/design.xml/OptimizableToArrayCall"><priority>3</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/design.xml/BadComparison"><priority>#</priority></rule>
<rule ref="rulesets/java/design.xml/EqualsNull"><priority>#</priority></rule>
-->
<rule ref="rulesets/java/design.xml/ConfusingTernary"><priority>4</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/design.xml/InstantiationToGetClass"><priority>3</priority></rule>
-->
<rule ref="rulesets/java/design.xml/IdempotentOperations"><priority>2</priority></rule>
<!-- Unused
<rule ref="rulesets/java/design.xml/SimpleDateFormatNeedsLocale"><priority>#</priority></rule>
-->
<rule ref="rulesets/java/design.xml/ImmutableField"><priority>3</priority></rule>
<!-- Unused
<rule ref="rulesets/java/design.xml/UseLocaleWithCaseConversions"><priority>#</priority></rule>
-->
<!-- Using Findbugs rule
<rule ref="rulesets/java/design.xml/AvoidProtectedFieldInFinalClass"><priority>4</priority></rule>
-->
<rule ref="rulesets/java/design.xml/AssignmentToNonFinalStatic"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/MissingStaticMethodInNonInstantiatableClass"><priority>2</priority></rule>
<rule ref="rulesets/java/design.xml/AvoidSynchronizedAtMethodLevel">
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//MethodDeclaration[
@Synchronized='true'
][
./MethodDeclarator[@Image!='getInstance']
or
.[@Static='false']
]
]]>
</value>
</property>
</properties>
</rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/design.xml/MissingBreakInSwitch"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/UseNotifyAllInsteadOfNotify"><priority>4</priority></rule>
-->
<rule ref="rulesets/java/design.xml/AvoidInstanceofChecksInCatchClause"><priority>4</priority></rule>
<rule ref="rulesets/java/design.xml/AbstractClassWithoutAbstractMethod"><priority>4</priority></rule>
<rule ref="rulesets/java/design.xml/SimplifyConditional"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/CompareObjectsWithEquals"><priority>2</priority></rule>
<rule ref="rulesets/java/design.xml/PositionLiteralsFirstInComparisons"><priority>3</priority></rule>
<!-- Unused
<rule ref="rulesets/java/design.xml/UnnecessaryLocalBeforeReturn"><priority>#</priority></rule>
-->
<rule ref="rulesets/java/design.xml/NonThreadSafeSingleton"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/UncommentedEmptyMethodBody"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/UncommentedEmptyConstructor"><priority>3</priority></rule>
<!-- Unused
<rule ref="rulesets/java/design.xml/ConstantsInInterface"><priority>#</priority></rule>
-->
<!-- Using Findbugs rule
<rule ref="rulesets/java/design.xml/UnsynchronizedStaticDateFormatter"><priority>2</priority></rule>
-->
<rule ref="rulesets/java/design.xml/PreserveStackTrace"><priority>2</priority></rule>
<rule ref="rulesets/java/design.xml/UseCollectionIsEmpty"><priority>3</priority></rule>
<rule ref="rulesets/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal"><priority>4</priority></rule>
<rule ref="rulesets/java/design.xml/EmptyMethodInAbstractClassShouldBeAbstract"><priority>4</priority></rule>
<rule ref="rulesets/java/design.xml/SingularField"><priority>4</priority></rule>
<!-- Unused
<rule ref="rulesets/java/design.xml/ReturnEmptyArrayRatherThanNull"><priority>#</priority></rule>
<rule ref="rulesets/java/design.xml/AbstractClassWithoutAnyMethod"><priority>#</priority></rule>
<rule ref="rulesets/java/design.xml/TooFewBranchesForASwitchStatement"><priority>#</priority></rule>
-->
<!-- Empty code Rules -->
<rule ref="rulesets/java/empty.xml/EmptyInitializer"><priority>4</priority></rule>
<rule ref="rulesets/java/empty.xml/EmptyStatementBlock"><priority>4</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/empty.xml/EmptySynchronizedBlock"><priority>2</priority></rule>
-->
<!-- Finalizer Rules -->
<rule ref="rulesets/java/finalizers.xml/EmptyFinalizer"><priority>2</priority></rule>
<rule ref="rulesets/java/finalizers.xml/FinalizeOnlyCallsSuperFinalize"><priority>2</priority></rule>
<rule ref="rulesets/java/finalizers.xml/FinalizeOverloaded"><priority>2</priority></rule>
<rule ref="rulesets/java/finalizers.xml/FinalizeDoesNotCallSuperFinalize"><priority>2</priority></rule>
<rule ref="rulesets/java/finalizers.xml/FinalizeShouldBeProtected"><priority>2</priority></rule>
<rule ref="rulesets/java/finalizers.xml/AvoidCallingFinalize"><priority>2</priority></rule>
<!-- Import Statement Rules -->
<rule ref="rulesets/java/imports.xml/DuplicateImports"><priority>4</priority></rule>
<rule ref="rulesets/java/imports.xml/DontImportJavaLang"><priority>4</priority></rule>
<rule ref="rulesets/java/imports.xml/UnusedImports"><priority>3</priority></rule>
<rule ref="rulesets/java/imports.xml/ImportFromSamePackage"><priority>4</priority></rule>
<rule ref="rulesets/java/imports.xml/TooManyStaticImports" message="Static imports are disallowed">
<priority>2</priority>
<properties>
<property name="maximumStaticImports" description="Static imports are disallowed">
<value>0</value>
</property>
</properties>
</rule>
<rule ref="rulesets/java/imports.xml/UnnecessaryFullyQualifiedName"><priority>5</priority></rule>
<!-- J2EE Rules -->
<rule ref="rulesets/java/j2ee.xml/UseProperClassLoader"><priority>2</priority></rule>
<rule ref="rulesets/java/j2ee.xml/MDBAndSessionBeanNamingConvention"><priority>4</priority></rule>
<rule ref="rulesets/java/j2ee.xml/RemoteSessionInterfaceNamingConvention"><priority>4</priority></rule>
<rule ref="rulesets/java/j2ee.xml/LocalInterfaceSessionNamingConvention"><priority>4</priority></rule>
<rule ref="rulesets/java/j2ee.xml/LocalHomeNamingConvention"><priority>4</priority></rule>
<rule ref="rulesets/java/j2ee.xml/RemoteInterfaceNamingConvention"><priority>4</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/j2ee.xml/DoNotCallSystemExit"><priority>1</priority></rule>
-->
<rule ref="rulesets/java/j2ee.xml/StaticEJBFieldShouldBeFinal"><priority>3</priority></rule>
<!-- Fix DoNotUseThreads - Runnables are not threads, jUnit tests are ok -->
<rule ref="rulesets/java/j2ee.xml/DoNotUseThreads">
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//ClassOrInterfaceType[
@Image = 'Thread'
][
not(
ancestor::ClassOrInterfaceDeclaration[
//ClassOrInterfaceType[typeof(@Image, 'junit.framework.TestCase','TestCase')]
or
//MarkerAnnotation/Name[typeof(@Image, 'org.junit.Test', 'Test')]
]
)
and
not(
ancestor::CastExpression
and
ancestor::LocalVariableDeclaration[
Type/ReferenceType/ClassOrInterfaceType[@Image = 'Thread']
]
)
]
]]>
</value>
</property>
</properties>
</rule>
<!-- JavaBean Rules -->
<rule ref="rulesets/java/javabeans.xml/BeanMembersShouldSerialize"><priority>2</priority></rule>
<!-- Unused
<rule ref="rulesets/java/javabeans.xml/MissingSerialVersionUID"><priority>#</priority></rule>
-->
<!-- JUnit Rules -->
<!-- Using Findbugs rule
<rule ref="rulesets/java/junit.xml/JUnitStaticSuite"><priority>3</priority></rule>
-->
<rule ref="rulesets/java/junit.xml/JUnitSpelling"><priority>3</priority></rule>
<rule ref="rulesets/java/junit.xml/JUnitAssertionsShouldIncludeMessage"><priority>3</priority></rule>
<rule ref="rulesets/java/junit.xml/JUnitTestContainsTooManyAsserts">
<priority>4</priority>
<properties>
<property name="maximumAsserts">
<value>20</value>
</property>
</properties>
</rule>
<rule ref="rulesets/java/junit.xml/JUnitTestsShouldIncludeAssert"><priority>3</priority></rule>
<rule ref="rulesets/java/junit.xml/TestClassWithoutTestCases"><priority>4</priority></rule>
<rule ref="rulesets/java/junit.xml/UnnecessaryBooleanAssertion"><priority>3</priority></rule>
<rule ref="rulesets/java/junit.xml/UseAssertTrueInsteadOfAssertEquals"><priority>5</priority></rule>
<!-- Fix UseAssertEqualsInsteadOfAssertTrue to allow use of e.g. Arrays.equals(array1, array2) -->
<rule ref="rulesets/java/junit.xml/UseAssertEqualsInsteadOfAssertTrue">
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//PrimaryExpression[
PrimaryPrefix/Name[@Image = 'assertTrue']
][
PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Name[
ends-with(@Image, '.equals')
][
count(../../PrimarySuffix/Arguments/ArgumentList/Expression) = 1
]
]
[
ancestor::ClassOrInterfaceDeclaration[
//ClassOrInterfaceType[typeof(@Image, 'junit.framework.TestCase','TestCase')]
or
//MarkerAnnotation/Name[typeof(@Image, 'org.junit.Test', 'Test')]
]
]
]]>
</value>
</property>
</properties>
</rule>
<!-- Fix UseAssertSameInsteadOfAssertTrue - assertSame can't be used for primitive types -->
<rule ref="rulesets/java/junit.xml/UseAssertSameInsteadOfAssertTrue">
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//PrimaryExpression[
PrimaryPrefix/Name[
@Image = 'assertTrue'
or
@Image = 'assertFalse'
]
][
PrimarySuffix/Arguments/ArgumentList/Expression/EqualityExpression[
count(.//NullLiteral) = 0
and count(.//BooleanLiteral) = 0
and count(.//Literal[matches(@Image, "^[0-9][0-9]*$")]) = 0]
][
ancestor::ClassOrInterfaceDeclaration[
//ClassOrInterfaceType[typeof(@Image, 'junit.framework.TestCase','TestCase')]
or
//MarkerAnnotation/Name[typeof(@Image, 'org.junit.Test', 'Test')]
]
]
]]>
</value>
</property>
</properties>
</rule>
<rule ref="rulesets/java/junit.xml/UseAssertNullInsteadOfAssertTrue"><priority>3</priority></rule>
<rule ref="rulesets/java/junit.xml/SimplifyBooleanAssertion"><priority>3</priority></rule>
<!-- Jakarta Commons Logging Rules -->
<!-- Unused (not using commons logging)
<rule ref="rulesets/java/logging-jakarta-commons.xml/UseCorrectExceptionLogging"><priority>#</priority></rule>
<rule ref="rulesets/java/logging-jakarta-commons.xml/ProperLogger"><priority>#</priority></rule>
<rule ref="rulesets/java/logging-jakarta-commons.xml/GuardDebugLogging"><priority>4</priority></rule>
<rule ref="rulesets/java/logging-jakarta-commons.xml.xml/GuardLogStatement"><priority>4</priority></rule>
<rule ref="rulesets/java/logging-jakarta-commons.xml/ProperLogger"><priority>4</priority></rule>
<rule ref="rulesets/java/logging-jakarta-commons.xml/UseCorrectExceptionLogging"><priority>3</priority></rule>
-->
<!-- Java Logging Rules -->
<rule ref="rulesets/java/logging-java.xml/MoreThanOneLogger"><priority>3</priority></rule>
<rule ref="rulesets/java/logging-java.xml/LoggerIsNotStaticFinal"><priority>3</priority></rule>
<rule ref="rulesets/java/logging-java.xml/SystemPrintln"><priority>2</priority></rule>
<rule ref="rulesets/java/logging-java.xml/AvoidPrintStackTrace"><priority>2</priority></rule>
<rule ref="rulesets/java/logging-java.xml/GuardLogStatementJavaUtil"><priority>4</priority></rule>
<!-- Unused
<rule ref="rulesets/java/logging-java.xml/InvalidSlf4jMessageFormat"><priority>5</priority></rule>
-->
<!-- Migration Rules -->
<rule ref="rulesets/java/migrating.xml/ReplaceVectorWithList"><priority>3</priority></rule>
<rule ref="rulesets/java/migrating.xml/ReplaceHashtableWithMap"><priority>3</priority></rule>
<rule ref="rulesets/java/migrating.xml/ReplaceEnumerationWithIterator"><priority>3</priority></rule>
<rule ref="rulesets/java/migrating.xml/AvoidEnumAsIdentifier"><priority>3</priority></rule>
<!-- Unused
<rule ref="rulesets/java/migrating.xml/AvoidAssertAsIdentifier"><priority>#</priority></rule>
<rule ref="rulesets/java/migrating.xml/IntegerInstantiation"><priority>#</priority></rule>
<rule ref="rulesets/java/migrating.xml/ByteInstantiation"><priority>#</priority></rule>
<rule ref="rulesets/java/migrating.xml/ShortInstantiation"><priority>#</priority></rule>
<rule ref="rulesets/java/migrating.xml/LongInstantiation"><priority>#</priority></rule>
<rule ref="rulesets/java/migrating.xml/JUnit4TestShouldUseBeforeAnnotation"><priority>#</priority></rule>
<rule ref="rulesets/java/migrating.xml/JUnit4TestShouldUseAfterAnnotation"><priority>#</priority></rule>
<rule ref="rulesets/java/migrating.xml/JUnit4TestShouldUseTestAnnotation"><priority>#</priority></rule>
<rule ref="rulesets/java/migrating.xml/JUnit4SuitesShouldUseSuiteAnnotation"><priority>#</priority></rule>
<rule ref="rulesets/java/migrating.xml/JUnitUseExpected"><priority>#</priority></rule>
-->
<!-- Naming Rules -->
<rule ref="rulesets/java/naming.xml/ShortVariable"><priority>4</priority></rule>
<!-- Unused
<rule ref="rulesets/java/naming.xml/LongVariable"><priority>#</priority></rule>
-->
<rule ref="rulesets/java/naming.xml/ShortMethodName"><priority>4</priority></rule>
<!-- Handled by Checkstyle
<rule ref="rulesets/java/naming.xml/ShortClassName"><priority>5</priority></rule>
-->
<!-- Unused
<rule ref="rulesets/java/naming.xml/VariableNamingConventions"><priority>#</priority></rule>
-->
<rule ref="rulesets/java/naming.xml/MethodNamingConventions"><priority>4</priority></rule>
<rule ref="rulesets/java/naming.xml/ClassNamingConventions"><priority>4</priority></rule>
<rule ref="rulesets/java/naming.xml/AbstractNaming"><priority>4</priority></rule>
<rule ref="rulesets/java/naming.xml/AvoidDollarSigns"><priority>3</priority></rule>
<rule ref="rulesets/java/naming.xml/GenericsNaming"><priority>5</priority></rule>
<rule ref="rulesets/java/naming.xml/MethodWithSameNameAsEnclosingClass"><priority>3</priority></rule>
<rule ref="rulesets/java/naming.xml/SuspiciousHashcodeMethodName"><priority>3</priority></rule>
<rule ref="rulesets/java/naming.xml/SuspiciousConstantFieldName"><priority>4</priority></rule>
<rule ref="rulesets/java/naming.xml/SuspiciousEqualsMethodName"><priority>3</priority></rule>
<rule ref="rulesets/java/naming.xml/AvoidFieldNameMatchingTypeName"><priority>3</priority></rule>
<rule ref="rulesets/java/naming.xml/AvoidFieldNameMatchingMethodName"><priority>3</priority></rule>
<rule ref="rulesets/java/naming.xml/NoPackage"><priority>3</priority></rule>
<rule ref="rulesets/java/naming.xml/PackageCase"><priority>4</priority></rule>
<rule ref="rulesets/java/naming.xml/MisleadingVariableName"><priority>4</priority></rule>
<rule ref="rulesets/java/naming.xml/BooleanGetMethodName"><priority>4</priority></rule>
<!-- Optimization Rules -->
<!-- Unused
<rule ref="rulesets/java/optimizations.xml/LocalVariableCouldBeFinal"><priority>4</priority></rule>
-->
<rule ref="rulesets/java/optimizations.xml/MethodArgumentCouldBeFinal"><priority>4</priority></rule>
<rule ref="rulesets/java/optimizations.xml/AvoidInstantiatingObjectsInLoops"><priority>5</priority></rule>
<rule ref="rulesets/java/optimizations.xml/UseArrayListInsteadOfVector"><priority>4</priority></rule>
<rule ref="rulesets/java/optimizations.xml/SimplifyStartsWith"><priority>4</priority></rule>
<rule ref="rulesets/java/optimizations.xml/UseStringBufferForStringAppends"><priority>3</priority></rule>
<rule ref="rulesets/java/optimizations.xml/UseArraysAsList"><priority>4</priority></rule>
<rule ref="rulesets/java/optimizations.xml/AvoidArrayLoops"><priority>4</priority></rule>
<rule ref="rulesets/java/optimizations.xml/UnnecessaryWrapperObjectCreation"><priority>3</priority></rule>
<rule ref="rulesets/java/optimizations.xml/AddEmptyString"><priority>3</priority></rule>
<rule ref="rulesets/java/optimizations.xml/PrematureDeclaration"><priority>5</priority></rule>
<!-- Unused
<rule ref="rulesets/java/optimizations.xml/RedundantFieldInitializer"><priority>5</priority></rule>
-->
<!-- Strict Exception Rules -->
<rule ref="rulesets/java/strictexception.xml/AvoidCatchingThrowable"><priority>2</priority></rule>
<rule ref="rulesets/java/strictexception.xml/AvoidCatchingGenericException"><priority>3</priority></rule>
<rule ref="rulesets/java/strictexception.xml/AvoidLosingExceptionInformation"><priority>3</priority></rule>
<rule ref="rulesets/java/strictexception.xml/AvoidThrowingNewInstanceOfSameException"><priority>3</priority></rule>
<rule ref="rulesets/java/strictexception.xml/SignatureDeclareThrowsException"><priority>3</priority></rule>
<rule ref="rulesets/java/strictexception.xml/ExceptionAsFlowControl"><priority>2</priority></rule>
<rule ref="rulesets/java/strictexception.xml/AvoidCatchingNPE"><priority>2</priority></rule>
<rule ref="rulesets/java/strictexception.xml/AvoidThrowingRawExceptionTypes"><priority>3</priority></rule>
<rule ref="rulesets/java/strictexception.xml/AvoidThrowingNullPointerException"><priority>3</priority></rule>
<rule ref="rulesets/java/strictexception.xml/AvoidRethrowingException"><priority>3</priority></rule>
<rule ref="rulesets/java/strictexception.xml/DoNotExtendJavaLangError"><priority>3</priority></rule>
<rule ref="rulesets/java/strictexception.xml/DoNotThrowExceptionInFinally"><priority>3</priority></rule>
<!-- String and StringBuffer Rules -->
<rule ref="rulesets/java/strings.xml/AvoidDuplicateLiterals"><priority>4</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/strings.xml/StringInstantiation"><priority>3</priority></rule>
<rule ref="rulesets/java/strings.xml/StringToString"><priority>3</priority></rule>
-->
<rule ref="rulesets/java/strings.xml/InefficientStringBuffering"><priority>3</priority></rule>
<rule ref="rulesets/java/strings.xml/UnnecessaryCaseChange"><priority>3</priority></rule>
<rule ref="rulesets/java/strings.xml/UseStringBufferLength"><priority>3</priority></rule>
<rule ref="rulesets/java/strings.xml/AppendCharacterWithChar"><priority>3</priority></rule>
<rule ref="rulesets/java/strings.xml/ConsecutiveLiteralAppends"><priority>4</priority></rule>
<rule ref="rulesets/java/strings.xml/UseIndexOfChar"><priority>4</priority></rule>
<rule ref="rulesets/java/strings.xml/InefficientEmptyStringCheck"><priority>3</priority></rule>
<rule ref="rulesets/java/strings.xml/InsufficientStringBufferDeclaration"><priority>4</priority></rule>
<rule ref="rulesets/java/strings.xml/UselessStringValueOf"><priority>3</priority></rule>
<rule ref="rulesets/java/strings.xml/StringBufferInstantiationWithChar"><priority>3</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/strings.xml/UseEqualsToCompareStrings"><priority>2</priority></rule>
-->
<rule ref="rulesets/java/strings.xml/AvoidStringBufferField"><priority>3</priority></rule>
<!-- Unused
<rule ref="rulesets/java/strings.xml/ConsecutiveAppendsShouldReuse"><priority>5</priority></rule>
-->
<!-- Security Code Guidelines -->
<rule ref="rulesets/java/sunsecure.xml/MethodReturnsInternalArray"><priority>4</priority></rule>
<rule ref="rulesets/java/sunsecure.xml/ArrayIsStoredDirectly"><priority>4</priority></rule>
<!-- Unused Code Rules -->
<rule ref="rulesets/java/unusedcode.xml/UnusedPrivateField"><priority>3</priority></rule>
<rule ref="rulesets/java/unusedcode.xml/UnusedLocalVariable"><priority>3</priority></rule>
<!-- Using Findbugs rule
<rule ref="rulesets/java/unusedcode.xml/UnusedPrivateMethod"><priority>3</priority></rule>
-->
<rule ref="rulesets/java/unusedcode.xml/UnusedFormalParameter"><priority>4</priority></rule>
<!-- Unnecessary Code Rules -->
<rule ref="rulesets/java/unnecessary.xml/UnusedNullCheckInEquals"><priority>3</priority></rule>
<rule ref="rulesets/java/unnecessary.xml/UselessOperationOnImmutable"><priority>2</priority></rule>
<rule ref="rulesets/java/unnecessary.xml/UselessOverridingMethod"><priority>3</priority></rule>
<rule ref="rulesets/java/unnecessary.xml/UnnecessaryFinalModifier"><priority>4</priority></rule>
<rule ref="rulesets/java/unnecessary.xml/UnnecessaryModifier"><priority>4</priority></rule>
<rule ref="rulesets/java/unnecessary.xml/UselessParentheses"><priority>5</priority></rule>
<rule ref="rulesets/java/unnecessary.xml/UselessQualifiedThis"><priority>4</priority></rule>
<!-- Empty Code Rules -->
<rule ref="rulesets/java/empty.xml/EmptyCatchBlock"><priority>3</priority></rule>
<rule ref="rulesets/java/empty.xml/EmptyIfStmt"><priority>2</priority></rule>
<rule ref="rulesets/java/empty.xml/EmptyFinallyBlock"><priority>3</priority></rule>
<rule ref="rulesets/java/empty.xml/EmptyStatementNotInLoop"><priority>3</priority></rule>
<rule ref="rulesets/java/empty.xml/EmptyStaticInitializer"><priority>3</priority></rule>
<rule ref="rulesets/java/empty.xml/EmptySwitchStatements"><priority>3</priority></rule>
<rule ref="rulesets/java/empty.xml/EmptyTryBlock"><priority>2</priority></rule>
<rule ref="rulesets/java/empty.xml/EmptyWhileStmt"><priority>2</priority></rule>
<!-- Unnecessary Code Rules -->
<rule ref="rulesets/java/unnecessary.xml/UnnecessaryReturn"><priority>3</priority></rule>
<rule ref="rulesets/java/unnecessary.xml/UnnecessaryConversionTemporary"><priority>3</priority></rule>
</ruleset>