├── .editorconfig ├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── .mvn ├── maven.config └── wrapper │ └── maven-wrapper.properties ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── RELEASE.md ├── docs ├── RULES.md ├── create_rules.groovy └── rules │ ├── AbstractClassWithoutAbstractMethod.md │ ├── AbstractClassWithoutAnyMethod.md │ ├── AbstractNaming.md │ ├── AccessorClassGeneration.md │ ├── AddEmptyString.md │ ├── AppendCharacterWithChar.md │ ├── ArrayIsStoredDirectly.md │ ├── AssignmentInOperand.md │ ├── AssignmentToNonFinalStatic.md │ ├── AtLeastOneConstructor.md │ ├── AvoidAccessibilityAlteration.md │ ├── AvoidArrayLoops.md │ ├── AvoidAssertAsIdentifier.md │ ├── AvoidBranchingStatementAsLastInLoop.md │ ├── AvoidCallingFinalize.md │ ├── AvoidCatchingGenericException.md │ ├── AvoidCatchingNPE.md │ ├── AvoidCatchingThrowable.md │ ├── AvoidConstantsInterface.md │ ├── AvoidDecimalLiteralsInBigDecimalConstructor.md │ ├── AvoidDeeplyNestedIfStmts.md │ ├── AvoidDollarSigns.md │ ├── AvoidDuplicateLiterals.md │ ├── AvoidEnumAsIdentifier.md │ ├── AvoidFieldNameMatchingMethodName.md │ ├── AvoidFieldNameMatchingTypeName.md │ ├── AvoidFinalLocalVariable.md │ ├── AvoidInstanceofChecksInCatchClause.md │ ├── AvoidInstantiatingObjectsInLoops.md │ ├── AvoidLiteralsInIfCondition.md │ ├── AvoidLosingExceptionInformation.md │ ├── AvoidMultipleUnaryOperators.md │ ├── AvoidPrefixingMethodParameters.md │ ├── AvoidPrintStackTrace.md │ ├── AvoidProtectedFieldInFinalClass.md │ ├── AvoidProtectedMethodInFinalClassNotExtending.md │ ├── AvoidReassigningParameters.md │ ├── AvoidRethrowingException.md │ ├── AvoidStringBufferField.md │ ├── AvoidSynchronizedAtMethodLevel.md │ ├── AvoidThreadGroup.md │ ├── AvoidThrowingNewInstanceOfSameException.md │ ├── AvoidThrowingNullPointerException.md │ ├── AvoidThrowingRawExceptionTypes.md │ ├── AvoidUsingHardCodedIP.md │ ├── AvoidUsingNativeCode.md │ ├── AvoidUsingOctalValues.md │ ├── AvoidUsingShortType.md │ ├── AvoidUsingVolatile.md │ ├── BadComparison.md │ ├── BeanMembersShouldSerialize.md │ ├── BigIntegerInstantiation.md │ ├── BooleanGetMethodName.md │ ├── BooleanInstantiation.md │ ├── BrokenNullCheck.md │ ├── ByteInstantiation.md │ ├── CallSuperFirst.md │ ├── CallSuperInConstructor.md │ ├── CallSuperLast.md │ ├── CheckResultSet.md │ ├── CheckSkipResult.md │ ├── ClassCastExceptionWithToArray.md │ ├── ClassNamingConventions.md │ ├── ClassWithOnlyPrivateConstructorsShouldBeFinal.md │ ├── CloneMethodMustBePublic.md │ ├── CloneMethodMustImplementCloneable.md │ ├── CloneMethodMustImplementCloneableWithTypeResolution.md │ ├── CloneMethodReturnTypeMustMatchClassName.md │ ├── CloneThrowsCloneNotSupportedException.md │ ├── CloseResource.md │ ├── CollapsibleIfStatements.md │ ├── CommentContent.md │ ├── CommentDefaultAccessModifier.md │ ├── CommentRequired.md │ ├── CommentSize.md │ ├── CompareObjectsWithEquals.md │ ├── ConfusingTernary.md │ ├── ConsecutiveAppendsShouldReuse.md │ ├── ConsecutiveLiteralAppends.md │ ├── ConstructorCallsOverridableMethod.md │ ├── CouplingBetweenObjects.md │ ├── CyclomaticComplexity.md │ ├── DataflowAnomalyAnalysis.md │ ├── DefaultLabelNotLastInSwitchStmt.md │ ├── DefaultPackage.md │ ├── DoNotCallGarbageCollectionExplicitly.md │ ├── DoNotCallSystemExit.md │ ├── DoNotExtendJavaLangError.md │ ├── DoNotHardCodeSDCard.md │ ├── DoNotThrowExceptionInFinally.md │ ├── DoNotUseThreads.md │ ├── DontCallThreadRun.md │ ├── DontImportJavaLang.md │ ├── DontImportSun.md │ ├── DontUseFloatTypeForLoopIndices.md │ ├── DoubleCheckedLocking.md │ ├── DuplicateImports.md │ ├── EmptyCatchBlock.md │ ├── EmptyFinalizer.md │ ├── EmptyFinallyBlock.md │ ├── EmptyIfStmt.md │ ├── EmptyInitializer.md │ ├── EmptyMethodInAbstractClassShouldBeAbstract.md │ ├── EmptyStatementBlock.md │ ├── EmptyStatementNotInLoop.md │ ├── EmptyStaticInitializer.md │ ├── EmptySwitchStatements.md │ ├── EmptySynchronizedBlock.md │ ├── EmptyTryBlock.md │ ├── EmptyWhileStmt.md │ ├── EqualsNull.md │ ├── ExceptionAsFlowControl.md │ ├── ExcessiveClassLength.md │ ├── ExcessiveImports.md │ ├── ExcessiveMethodLength.md │ ├── ExcessiveParameterList.md │ ├── ExcessivePublicCount.md │ ├── ExtendsObject.md │ ├── FieldDeclarationsShouldBeAtStartOfClass.md │ ├── FinalFieldCouldBeStatic.md │ ├── FinalizeDoesNotCallSuperFinalize.md │ ├── FinalizeOnlyCallsSuperFinalize.md │ ├── FinalizeOverloaded.md │ ├── FinalizeShouldBeProtected.md │ ├── ForLoopShouldBeWhileLoop.md │ ├── ForLoopsMustUseBraces.md │ ├── GenericsNaming.md │ ├── GodClass.md │ ├── GuardDebugLogging.md │ ├── GuardLogStatement.md │ ├── GuardLogStatementJavaUtil.md │ ├── IdempotentOperations.md │ ├── IfElseStmtsMustUseBraces.md │ ├── IfStmtsMustUseBraces.md │ ├── ImmutableField.md │ ├── ImportFromSamePackage.md │ ├── InefficientEmptyStringCheck.md │ ├── InefficientStringBuffering.md │ ├── InstantiationToGetClass.md │ ├── InsufficientStringBufferDeclaration.md │ ├── IntegerInstantiation.md │ ├── JUnit4SuitesShouldUseSuiteAnnotation.md │ ├── JUnit4TestShouldUseAfterAnnotation.md │ ├── JUnit4TestShouldUseBeforeAnnotation.md │ ├── JUnit4TestShouldUseTestAnnotation.md │ ├── JUnitAssertionsShouldIncludeMessage.md │ ├── JUnitSpelling.md │ ├── JUnitStaticSuite.md │ ├── JUnitTestContainsTooManyAsserts.md │ ├── JUnitTestsShouldIncludeAssert.md │ ├── JUnitUseExpected.md │ ├── JumbledIncrementer.md │ ├── LawOfDemeter.md │ ├── LocalHomeNamingConvention.md │ ├── LocalInterfaceSessionNamingConvention.md │ ├── LocalVariableCouldBeFinal.md │ ├── LoggerIsNotStaticFinal.md │ ├── LogicInversion.md │ ├── LongInstantiation.md │ ├── LongVariable.md │ ├── LooseCoupling.md │ ├── LooseCouplingWithTypeResolution.md │ ├── LoosePackageCoupling.md │ ├── MDBAndSessionBeanNamingConvention.md │ ├── MethodArgumentCouldBeFinal.md │ ├── MethodNamingConventions.md │ ├── MethodReturnsInternalArray.md │ ├── MethodWithSameNameAsEnclosingClass.md │ ├── MisleadingVariableName.md │ ├── MisplacedNullCheck.md │ ├── MissingBreakInSwitch.md │ ├── MissingSerialVersionUID.md │ ├── MissingStaticMethodInNonInstantiatableClass.md │ ├── ModifiedCyclomaticComplexity.md │ ├── MoreThanOneLogger.md │ ├── NPathComplexity.md │ ├── NcssConstructorCount.md │ ├── NcssMethodCount.md │ ├── NcssTypeCount.md │ ├── NoPackage.md │ ├── NonCaseLabelInSwitchStatement.md │ ├── NonStaticInitializer.md │ ├── NonThreadSafeSingleton.md │ ├── NullAssignment.md │ ├── OneDeclarationPerLine.md │ ├── OnlyOneReturn.md │ ├── OptimizableToArrayCall.md │ ├── OverrideBothEqualsAndHashcode.md │ ├── PackageCase.md │ ├── PositionLiteralsFirstInCaseInsensitiveComparisons.md │ ├── PositionLiteralsFirstInComparisons.md │ ├── PrematureDeclaration.md │ ├── PreserveStackTrace.md │ ├── ProperCloneImplementation.md │ ├── ProperLogger.md │ ├── RedundantFieldInitializer.md │ ├── RemoteInterfaceNamingConvention.md │ ├── RemoteSessionInterfaceNamingConvention.md │ ├── ReplaceEnumerationWithIterator.md │ ├── ReplaceHashtableWithMap.md │ ├── ReplaceVectorWithList.md │ ├── ReturnEmptyArrayRatherThanNull.md │ ├── ReturnFromFinallyBlock.md │ ├── ShortClassName.md │ ├── ShortInstantiation.md │ ├── ShortMethodName.md │ ├── ShortVariable.md │ ├── SignatureDeclareThrowsException.md │ ├── SignatureDeclareThrowsExceptionWithTypeResolution.md │ ├── SimpleDateFormatNeedsLocale.md │ ├── SimplifiedTernary.md │ ├── SimplifyBooleanAssertion.md │ ├── SimplifyBooleanExpressions.md │ ├── SimplifyBooleanReturns.md │ ├── SimplifyConditional.md │ ├── SimplifyStartsWith.md │ ├── SingleMethodSingleton.md │ ├── SingletonClassReturningNewInstance.md │ ├── SingularField.md │ ├── StaticEJBFieldShouldBeFinal.md │ ├── StdCyclomaticComplexity.md │ ├── StringBufferInstantiationWithChar.md │ ├── StringInstantiation.md │ ├── StringToString.md │ ├── SuspiciousConstantFieldName.md │ ├── SuspiciousEqualsMethodName.md │ ├── SuspiciousHashcodeMethodName.md │ ├── SuspiciousOctalEscape.md │ ├── SwitchDensity.md │ ├── SwitchStmtsShouldHaveDefault.md │ ├── SystemPrintln.md │ ├── TestClassWithoutTestCases.md │ ├── TooFewBranchesForASwitchStatement.md │ ├── TooManyFields.md │ ├── TooManyMethods.md │ ├── TooManyStaticImports.md │ ├── UncommentedEmptyConstructor.md │ ├── UncommentedEmptyMethodBody.md │ ├── UnconditionalIfStatement.md │ ├── UnnecessaryBooleanAssertion.md │ ├── UnnecessaryCaseChange.md │ ├── UnnecessaryConstructor.md │ ├── UnnecessaryConversionTemporary.md │ ├── UnnecessaryFinalModifier.md │ ├── UnnecessaryFullyQualifiedName.md │ ├── UnnecessaryLocalBeforeReturn.md │ ├── UnnecessaryParentheses.md │ ├── UnnecessaryReturn.md │ ├── UnnecessaryWrapperObjectCreation.md │ ├── UnsynchronizedStaticDateFormatter.md │ ├── UnusedAssignment.md │ ├── UnusedFormalParameter.md │ ├── UnusedImports.md │ ├── UnusedImportsWithTypeResolution.md │ ├── UnusedLocalVariable.md │ ├── UnusedModifier.md │ ├── UnusedNullCheckInEquals.md │ ├── UnusedPrivateField.md │ ├── UnusedPrivateMethod.md │ ├── UseArrayListInsteadOfVector.md │ ├── UseArraysAsList.md │ ├── UseAssertEqualsInsteadOfAssertTrue.md │ ├── UseAssertNullInsteadOfAssertTrue.md │ ├── UseAssertSameInsteadOfAssertTrue.md │ ├── UseAssertTrueInsteadOfAssertEquals.md │ ├── UseCollectionIsEmpty.md │ ├── UseConcurrentHashMap.md │ ├── UseCorrectExceptionLogging.md │ ├── UseEqualsToCompareStrings.md │ ├── UseIndexOfChar.md │ ├── UseLocaleWithCaseConversions.md │ ├── UseNotifyAllInsteadOfNotify.md │ ├── UseObjectForClearerAPI.md │ ├── UseProperClassLoader.md │ ├── UseStringBufferForStringAppends.md │ ├── UseStringBufferLength.md │ ├── UseUtilityClass.md │ ├── UseVarargs.md │ ├── UselessOperationOnImmutable.md │ ├── UselessOverridingMethod.md │ ├── UselessParentheses.md │ ├── UselessQualifiedThis.md │ ├── UselessStringValueOf.md │ ├── VariableNamingConventions.md │ ├── WhileLoopsMustUseBraces.md │ └── XPathRule.md ├── integration-test ├── pom.xml ├── projects │ ├── pmd-avoid-duplicate-literals │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── AvoidDuplicateLiterals.java │ ├── pmd-extensions │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── pmd │ │ │ ├── Bar.java │ │ │ ├── Errors.java │ │ │ └── Foo.java │ └── pmd-junit-rules │ │ ├── pom.xml │ │ └── src │ │ ├── main │ │ └── java │ │ │ └── ProductionCode.java │ │ └── test │ │ └── java │ │ └── ProductionCodeTest.java └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── sonar │ │ │ └── examples │ │ │ └── pmd │ │ │ ├── MaximumMethodsCountCheck.java │ │ │ ├── PmdExtensionPlugin.java │ │ │ └── PmdExtensionRepository.java │ └── resources │ │ └── org │ │ └── sonar │ │ └── examples │ │ └── pmd │ │ ├── extensions.xml │ │ └── rulesets.xml │ └── test │ ├── java │ └── com │ │ └── sonar │ │ └── it │ │ └── java │ │ └── suite │ │ ├── DefinedJavaVersion.java │ │ ├── PmdIT.java │ │ ├── TestUtils.java │ │ └── orchestrator │ │ └── PmdTestOrchestrator.java │ └── resources │ ├── TestUtils.txt │ └── com │ └── sonar │ └── it │ └── java │ └── PmdTest │ ├── pmd-all-rules.xml │ ├── pmd-backup.xml │ └── pmd-extensions-profile.xml ├── mvnw ├── mvnw.cmd ├── pom.xml └── sonar-pmd-plugin ├── pom.xml └── src ├── main ├── java │ └── org │ │ └── sonar │ │ └── plugins │ │ └── pmd │ │ ├── PmdConfiguration.java │ │ ├── PmdConstants.java │ │ ├── PmdExecutor.java │ │ ├── PmdLevelUtils.java │ │ ├── PmdPlugin.java │ │ ├── PmdPriorities.java │ │ ├── PmdSensor.java │ │ ├── PmdTemplate.java │ │ ├── PmdViolationRecorder.java │ │ ├── ProjectDataSource.java │ │ ├── TextRangeCalculator.java │ │ ├── rule │ │ ├── ExternalDescriptionLoader.java │ │ ├── PmdKotlinRulesDefinition.java │ │ ├── PmdRulesDefinition.java │ │ └── PmdUnitTestsRulesDefinition.java │ │ └── xml │ │ ├── PmdProperty.java │ │ ├── PmdRule.java │ │ ├── PmdRuleSet.java │ │ ├── PmdRuleSets.java │ │ └── factory │ │ ├── ActiveRulesRuleSetFactory.java │ │ ├── RuleSetFactory.java │ │ ├── RulesProfileRuleSetFactory.java │ │ └── XmlRuleSetFactory.java └── resources │ ├── com │ └── sonar │ │ └── sqale │ │ ├── pmd-model-kotlin.xml │ │ └── pmd-model.xml │ └── org │ └── sonar │ ├── l10n │ ├── pmd-kotlin.properties │ ├── pmd.properties │ └── pmd │ │ └── rules │ │ ├── pmd-kotlin │ │ └── FunctionNameTooShort.html │ │ ├── pmd-unit-tests │ │ ├── JUnit4SuitesShouldUseSuiteAnnotation.html │ │ ├── JUnit4TestShouldUseAfterAnnotation.html │ │ ├── JUnit4TestShouldUseBeforeAnnotation.html │ │ ├── JUnit4TestShouldUseTestAnnotation.html │ │ ├── JUnitAssertionsShouldIncludeMessage.html │ │ ├── JUnitSpelling.html │ │ ├── JUnitStaticSuite.html │ │ ├── JUnitTestContainsTooManyAsserts.html │ │ ├── JUnitTestsShouldIncludeAssert.html │ │ ├── JUnitUseExpected.html │ │ ├── SimplifyBooleanAssertion.html │ │ ├── TestClassWithoutTestCases.html │ │ ├── UnnecessaryBooleanAssertion.html │ │ ├── UseAssertEqualsInsteadOfAssertTrue.html │ │ ├── UseAssertNullInsteadOfAssertTrue.html │ │ ├── UseAssertSameInsteadOfAssertTrue.html │ │ └── UseAssertTrueInsteadOfAssertEquals.html │ │ └── pmd │ │ ├── AbstractClassWithoutAbstractMethod.html │ │ ├── AbstractClassWithoutAnyMethod.html │ │ ├── AbstractNaming.html │ │ ├── AccessorClassGeneration.html │ │ ├── AddEmptyString.html │ │ ├── AppendCharacterWithChar.html │ │ ├── ArrayIsStoredDirectly.html │ │ ├── AssignmentInOperand.html │ │ ├── AssignmentToNonFinalStatic.html │ │ ├── AtLeastOneConstructor.html │ │ ├── AvoidAccessibilityAlteration.html │ │ ├── AvoidArrayLoops.html │ │ ├── AvoidAssertAsIdentifier.html │ │ ├── AvoidBranchingStatementAsLastInLoop.html │ │ ├── AvoidCallingFinalize.html │ │ ├── AvoidCatchingGenericException.html │ │ ├── AvoidCatchingNPE.html │ │ ├── AvoidCatchingThrowable.html │ │ ├── AvoidConstantsInterface.html │ │ ├── AvoidDecimalLiteralsInBigDecimalConstructor.html │ │ ├── AvoidDeeplyNestedIfStmts.html │ │ ├── AvoidDollarSigns.html │ │ ├── AvoidDuplicateLiterals.html │ │ ├── AvoidEnumAsIdentifier.html │ │ ├── AvoidFieldNameMatchingMethodName.html │ │ ├── AvoidFieldNameMatchingTypeName.html │ │ ├── AvoidFinalLocalVariable.html │ │ ├── AvoidInstanceofChecksInCatchClause.html │ │ ├── AvoidInstantiatingObjectsInLoops.html │ │ ├── AvoidLiteralsInIfCondition.html │ │ ├── AvoidLosingExceptionInformation.html │ │ ├── AvoidMultipleUnaryOperators.html │ │ ├── AvoidPrefixingMethodParameters.html │ │ ├── AvoidPrintStackTrace.html │ │ ├── AvoidProtectedFieldInFinalClass.html │ │ ├── AvoidProtectedMethodInFinalClassNotExtending.html │ │ ├── AvoidReassigningParameters.html │ │ ├── AvoidRethrowingException.html │ │ ├── AvoidStringBufferField.html │ │ ├── AvoidSynchronizedAtMethodLevel.html │ │ ├── AvoidThreadGroup.html │ │ ├── AvoidThrowingNewInstanceOfSameException.html │ │ ├── AvoidThrowingNullPointerException.html │ │ ├── AvoidThrowingRawExceptionTypes.html │ │ ├── AvoidUsingHardCodedIP.html │ │ ├── AvoidUsingNativeCode.html │ │ ├── AvoidUsingOctalValues.html │ │ ├── AvoidUsingShortType.html │ │ ├── AvoidUsingVolatile.html │ │ ├── BadComparison.html │ │ ├── BeanMembersShouldSerialize.html │ │ ├── BigIntegerInstantiation.html │ │ ├── BooleanGetMethodName.html │ │ ├── BooleanInstantiation.html │ │ ├── BrokenNullCheck.html │ │ ├── ByteInstantiation.html │ │ ├── CallSuperFirst.html │ │ ├── CallSuperInConstructor.html │ │ ├── CallSuperLast.html │ │ ├── CheckResultSet.html │ │ ├── CheckSkipResult.html │ │ ├── ClassCastExceptionWithToArray.html │ │ ├── ClassNamingConventions.html │ │ ├── ClassWithOnlyPrivateConstructorsShouldBeFinal.html │ │ ├── CloneMethodMustBePublic.html │ │ ├── CloneMethodMustImplementCloneable.html │ │ ├── CloneMethodMustImplementCloneableWithTypeResolution.html │ │ ├── CloneMethodReturnTypeMustMatchClassName.html │ │ ├── CloneThrowsCloneNotSupportedException.html │ │ ├── CloseResource.html │ │ ├── CollapsibleIfStatements.html │ │ ├── CommentContent.html │ │ ├── CommentDefaultAccessModifier.html │ │ ├── CommentRequired.html │ │ ├── CommentSize.html │ │ ├── CompareObjectsWithEquals.html │ │ ├── ConfusingTernary.html │ │ ├── ConsecutiveAppendsShouldReuse.html │ │ ├── ConsecutiveLiteralAppends.html │ │ ├── ConstructorCallsOverridableMethod.html │ │ ├── CouplingBetweenObjects.html │ │ ├── CyclomaticComplexity.html │ │ ├── DataflowAnomalyAnalysis.html │ │ ├── DefaultLabelNotLastInSwitchStmt.html │ │ ├── DefaultPackage.html │ │ ├── DoNotCallGarbageCollectionExplicitly.html │ │ ├── DoNotCallSystemExit.html │ │ ├── DoNotExtendJavaLangError.html │ │ ├── DoNotHardCodeSDCard.html │ │ ├── DoNotThrowExceptionInFinally.html │ │ ├── DoNotUseThreads.html │ │ ├── DontCallThreadRun.html │ │ ├── DontImportJavaLang.html │ │ ├── DontImportSun.html │ │ ├── DontUseFloatTypeForLoopIndices.html │ │ ├── DoubleCheckedLocking.html │ │ ├── DuplicateImports.html │ │ ├── EmptyCatchBlock.html │ │ ├── EmptyFinalizer.html │ │ ├── EmptyFinallyBlock.html │ │ ├── EmptyIfStmt.html │ │ ├── EmptyInitializer.html │ │ ├── EmptyMethodInAbstractClassShouldBeAbstract.html │ │ ├── EmptyStatementBlock.html │ │ ├── EmptyStatementNotInLoop.html │ │ ├── EmptyStaticInitializer.html │ │ ├── EmptySwitchStatements.html │ │ ├── EmptySynchronizedBlock.html │ │ ├── EmptyTryBlock.html │ │ ├── EmptyWhileStmt.html │ │ ├── EqualsNull.html │ │ ├── ExceptionAsFlowControl.html │ │ ├── ExcessiveClassLength.html │ │ ├── ExcessiveImports.html │ │ ├── ExcessiveMethodLength.html │ │ ├── ExcessiveParameterList.html │ │ ├── ExcessivePublicCount.html │ │ ├── ExtendsObject.html │ │ ├── FieldDeclarationsShouldBeAtStartOfClass.html │ │ ├── FinalFieldCouldBeStatic.html │ │ ├── FinalizeDoesNotCallSuperFinalize.html │ │ ├── FinalizeOnlyCallsSuperFinalize.html │ │ ├── FinalizeOverloaded.html │ │ ├── FinalizeShouldBeProtected.html │ │ ├── ForLoopShouldBeWhileLoop.html │ │ ├── ForLoopsMustUseBraces.html │ │ ├── GenericsNaming.html │ │ ├── GodClass.html │ │ ├── GuardDebugLogging.html │ │ ├── GuardLogStatement.html │ │ ├── GuardLogStatementJavaUtil.html │ │ ├── IdempotentOperations.html │ │ ├── IfElseStmtsMustUseBraces.html │ │ ├── IfStmtsMustUseBraces.html │ │ ├── ImmutableField.html │ │ ├── ImportFromSamePackage.html │ │ ├── InefficientEmptyStringCheck.html │ │ ├── InefficientStringBuffering.html │ │ ├── InstantiationToGetClass.html │ │ ├── InsufficientStringBufferDeclaration.html │ │ ├── IntegerInstantiation.html │ │ ├── JumbledIncrementer.html │ │ ├── LawOfDemeter.html │ │ ├── LocalHomeNamingConvention.html │ │ ├── LocalInterfaceSessionNamingConvention.html │ │ ├── LocalVariableCouldBeFinal.html │ │ ├── LoggerIsNotStaticFinal.html │ │ ├── LogicInversion.html │ │ ├── LongInstantiation.html │ │ ├── LongVariable.html │ │ ├── LooseCoupling.html │ │ ├── LooseCouplingWithTypeResolution.html │ │ ├── LoosePackageCoupling.html │ │ ├── MDBAndSessionBeanNamingConvention.html │ │ ├── MethodArgumentCouldBeFinal.html │ │ ├── MethodNamingConventions.html │ │ ├── MethodReturnsInternalArray.html │ │ ├── MethodWithSameNameAsEnclosingClass.html │ │ ├── MisleadingVariableName.html │ │ ├── MisplacedNullCheck.html │ │ ├── MissingBreakInSwitch.html │ │ ├── MissingSerialVersionUID.html │ │ ├── MissingStaticMethodInNonInstantiatableClass.html │ │ ├── ModifiedCyclomaticComplexity.html │ │ ├── MoreThanOneLogger.html │ │ ├── NPathComplexity.html │ │ ├── NcssConstructorCount.html │ │ ├── NcssMethodCount.html │ │ ├── NcssTypeCount.html │ │ ├── NoPackage.html │ │ ├── NonCaseLabelInSwitchStatement.html │ │ ├── NonStaticInitializer.html │ │ ├── NonThreadSafeSingleton.html │ │ ├── NullAssignment.html │ │ ├── OneDeclarationPerLine.html │ │ ├── OnlyOneReturn.html │ │ ├── OptimizableToArrayCall.html │ │ ├── OverrideBothEqualsAndHashcode.html │ │ ├── PackageCase.html │ │ ├── PositionLiteralsFirstInCaseInsensitiveComparisons.html │ │ ├── PositionLiteralsFirstInComparisons.html │ │ ├── PrematureDeclaration.html │ │ ├── PreserveStackTrace.html │ │ ├── ProperCloneImplementation.html │ │ ├── ProperLogger.html │ │ ├── RedundantFieldInitializer.html │ │ ├── RemoteInterfaceNamingConvention.html │ │ ├── RemoteSessionInterfaceNamingConvention.html │ │ ├── ReplaceEnumerationWithIterator.html │ │ ├── ReplaceHashtableWithMap.html │ │ ├── ReplaceVectorWithList.html │ │ ├── ReturnEmptyArrayRatherThanNull.html │ │ ├── ReturnFromFinallyBlock.html │ │ ├── ShortClassName.html │ │ ├── ShortInstantiation.html │ │ ├── ShortMethodName.html │ │ ├── ShortVariable.html │ │ ├── SignatureDeclareThrowsException.html │ │ ├── SignatureDeclareThrowsExceptionWithTypeResolution.html │ │ ├── SimpleDateFormatNeedsLocale.html │ │ ├── SimplifiedTernary.html │ │ ├── SimplifyBooleanExpressions.html │ │ ├── SimplifyBooleanReturns.html │ │ ├── SimplifyConditional.html │ │ ├── SimplifyStartsWith.html │ │ ├── SingleMethodSingleton.html │ │ ├── SingletonClassReturningNewInstance.html │ │ ├── SingularField.html │ │ ├── StaticEJBFieldShouldBeFinal.html │ │ ├── StdCyclomaticComplexity.html │ │ ├── StringBufferInstantiationWithChar.html │ │ ├── StringInstantiation.html │ │ ├── StringToString.html │ │ ├── SuspiciousConstantFieldName.html │ │ ├── SuspiciousEqualsMethodName.html │ │ ├── SuspiciousHashcodeMethodName.html │ │ ├── SuspiciousOctalEscape.html │ │ ├── SwitchDensity.html │ │ ├── SwitchStmtsShouldHaveDefault.html │ │ ├── SystemPrintln.html │ │ ├── TooFewBranchesForASwitchStatement.html │ │ ├── TooManyFields.html │ │ ├── TooManyMethods.html │ │ ├── TooManyStaticImports.html │ │ ├── UncommentedEmptyConstructor.html │ │ ├── UncommentedEmptyMethodBody.html │ │ ├── UnconditionalIfStatement.html │ │ ├── UnnecessaryCaseChange.html │ │ ├── UnnecessaryConstructor.html │ │ ├── UnnecessaryConversionTemporary.html │ │ ├── UnnecessaryFinalModifier.html │ │ ├── UnnecessaryFullyQualifiedName.html │ │ ├── UnnecessaryLocalBeforeReturn.html │ │ ├── UnnecessaryParentheses.html │ │ ├── UnnecessaryReturn.html │ │ ├── UnnecessaryWrapperObjectCreation.html │ │ ├── UnsynchronizedStaticDateFormatter.html │ │ ├── UnusedAssignment.html │ │ ├── UnusedFormalParameter.html │ │ ├── UnusedImports.html │ │ ├── UnusedImportsWithTypeResolution.html │ │ ├── UnusedLocalVariable.html │ │ ├── UnusedModifier.html │ │ ├── UnusedNullCheckInEquals.html │ │ ├── UnusedPrivateField.html │ │ ├── UnusedPrivateMethod.html │ │ ├── UseArrayListInsteadOfVector.html │ │ ├── UseArraysAsList.html │ │ ├── UseCollectionIsEmpty.html │ │ ├── UseConcurrentHashMap.html │ │ ├── UseCorrectExceptionLogging.html │ │ ├── UseEqualsToCompareStrings.html │ │ ├── UseIndexOfChar.html │ │ ├── UseLocaleWithCaseConversions.html │ │ ├── UseNotifyAllInsteadOfNotify.html │ │ ├── UseObjectForClearerAPI.html │ │ ├── UseProperClassLoader.html │ │ ├── UseStringBufferForStringAppends.html │ │ ├── UseStringBufferLength.html │ │ ├── UseUtilityClass.html │ │ ├── UseVarargs.html │ │ ├── UselessOperationOnImmutable.html │ │ ├── UselessOverridingMethod.html │ │ ├── UselessParentheses.html │ │ ├── UselessQualifiedThis.html │ │ ├── UselessStringValueOf.html │ │ ├── VariableNamingConventions.html │ │ ├── WhileLoopsMustUseBraces.html │ │ └── XPathRule.html │ └── plugins │ └── pmd │ ├── profile-sonar-way.xml │ ├── rules-kotlin.xml │ ├── rules-unit-tests.xml │ └── rules.xml └── test ├── java └── org │ └── sonar │ └── plugins │ └── pmd │ ├── PmdConfigurationTest.java │ ├── PmdConstantsTest.java │ ├── PmdExecutorTest.java │ ├── PmdKotlinRulesDefinitionTest.java │ ├── PmdPluginTest.java │ ├── PmdPrioritiesTest.java │ ├── PmdRulesDefinitionTest.java │ ├── PmdSensorTest.java │ ├── PmdTemplateTest.java │ ├── PmdTestUtils.java │ ├── PmdUnitTestsRulesDefinitionTest.java │ ├── PmdViolationRecorderTest.java │ ├── TextRangeCalculatorTest.java │ ├── rule │ └── ExternalDescriptionLoaderTest.java │ └── xml │ └── PmdRuleSetsTest.java ├── kotlin └── TestKotlin.kt └── resources └── org └── sonar ├── l10n └── languageKey │ └── rules │ └── repoKey │ └── ruleWithExternalInfo.html └── plugins └── pmd ├── complex-with-unknown-nodes.xml ├── export_rule_with_all_params_empty.xml ├── export_rule_with_empty_param.xml ├── export_simple.xml ├── export_xpath_rules.xml ├── junit.xml ├── simple-kotlin.xml ├── simple.xml └── source.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # ---- Maven 2 | target/ 3 | 4 | # ---- IntelliJ IDEA 5 | *.iws 6 | *.iml 7 | *.ipr 8 | .idea/ 9 | 10 | # ---- Eclipse 11 | .classpath 12 | .project 13 | .settings 14 | 15 | # ---- Mac OS X 16 | .DS_Store? 17 | Icon? 18 | # Thumbnails 19 | ._* 20 | # Files that might appear on external disk 21 | .Spotlight-V100 22 | .Trashes 23 | 24 | # ---- Windows 25 | # Windows image file caches 26 | Thumbs.db 27 | # Folder config file 28 | Desktop.ini 29 | .java-version 30 | 31 | .flattened-pom.xml 32 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -Drevision=4.1.0-SNAPSHOT 2 | -------------------------------------------------------------------------------- /docs/rules/AbstractNaming.md: -------------------------------------------------------------------------------- 1 | # AbstractNaming 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AbstractNaming`
4 | > :warning: This rule is **deprecated** in favour of [S118](https://rules.sonarsource.com/java/RSPEC-118). 5 | 6 | ----- 7 | 8 | 9 | Abstract classes should be named 'AbstractXXX'. 10 |

Example:

h2> 11 |
12 | public abstract class Foo { // should be AbstractFoo
13 | }
14 |   
15 | -------------------------------------------------------------------------------- /docs/rules/AddEmptyString.md: -------------------------------------------------------------------------------- 1 | # AddEmptyString 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AddEmptyString`
4 | 5 | 6 | ----- 7 | 8 | 9 | The conversion of literals to strings by concatenating them with empty strings is inefficient. 10 | It is much better to use one of the type-specific toString() methods instead. 11 | 12 |

Example:

13 |
14 | String s = "" + 123;                // inefficient
15 | String t = Integer.toString(456);   // preferred approach
16 | 
17 | -------------------------------------------------------------------------------- /docs/rules/ArrayIsStoredDirectly.md: -------------------------------------------------------------------------------- 1 | # ArrayIsStoredDirectly 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ArrayIsStoredDirectly`
4 | > :warning: This rule is **deprecated** in favour of [S2384](https://rules.sonarsource.com/java/RSPEC-2384). 5 | 6 | ----- 7 | 8 | 9 | Constructors and methods receiving arrays should clone objects and store the copy. This prevents future changes from the user from affecting the original array. 10 | -------------------------------------------------------------------------------- /docs/rules/AssignmentInOperand.md: -------------------------------------------------------------------------------- 1 | # AssignmentInOperand 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AssignmentInOperand`
4 | > :warning: This rule is **deprecated** in favour of `java:AssignmentInSubExpressionCheck`. 5 | 6 | ----- 7 | 8 | 9 | Avoid assignments in operands; this can make code more complicated and harder to read. 10 | 11 |

Example:

12 |
13 | public void bar() {
14 |   int x = 2;
15 |   if ((x = getX()) == 3) {
16 |     System.out.println("3!");
17 |   }
18 | }
19 | 
20 | -------------------------------------------------------------------------------- /docs/rules/AssignmentToNonFinalStatic.md: -------------------------------------------------------------------------------- 1 | # AssignmentToNonFinalStatic 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AssignmentToNonFinalStatic`
4 | 5 | 6 | ----- 7 | 8 | 9 | Identifies a possible unsafe usage of a static field. 10 | 11 |

Example:

12 |
13 | public class StaticField {
14 |  static int x;
15 |  public FinalFields(int y) {
16 |   x = y; // unsafe
17 |  }
18 | }
19 | 
20 | -------------------------------------------------------------------------------- /docs/rules/AtLeastOneConstructor.md: -------------------------------------------------------------------------------- 1 | # AtLeastOneConstructor 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AtLeastOneConstructor`
4 | > :warning: This rule is **deprecated** in favour of [S1118](https://rules.sonarsource.com/java/RSPEC-1118), [S1258](https://rules.sonarsource.com/java/RSPEC-1258). 5 | 6 | ----- 7 | 8 | Each non-static class should declare at least one constructor. Classes with solely static members ("Utility class") are ignored. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidAssertAsIdentifier.md: -------------------------------------------------------------------------------- 1 | # AvoidAssertAsIdentifier 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidAssertAsIdentifier`
4 | > :warning: This rule is **deprecated** in favour of [S1190](https://rules.sonarsource.com/java/RSPEC-1190). 5 | 6 | ----- 7 | 8 | 9 | Use of the term assert will conflict with newer versions of Java since it is a reserved word. 10 | -------------------------------------------------------------------------------- /docs/rules/AvoidCatchingGenericException.md: -------------------------------------------------------------------------------- 1 | # AvoidCatchingGenericException 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidCatchingGenericException`
4 | > :warning: This rule is **deprecated** in favour of [S2221](https://rules.sonarsource.com/java/RSPEC-2221). 5 | 6 | ----- 7 | 8 | 9 | Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block. 10 | -------------------------------------------------------------------------------- /docs/rules/AvoidCatchingNPE.md: -------------------------------------------------------------------------------- 1 | # AvoidCatchingNPE 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidCatchingNPE`
4 | > :warning: This rule is **deprecated** in favour of [S1696](https://rules.sonarsource.com/java/RSPEC-1696). 5 | 6 | ----- 7 | 8 | 9 | Code should never throw NullPointerExceptions under normal circumstances. 10 | A catch block may hide the original error, causing other, more subtle problems later on. 11 | -------------------------------------------------------------------------------- /docs/rules/AvoidCatchingThrowable.md: -------------------------------------------------------------------------------- 1 | # AvoidCatchingThrowable 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidCatchingThrowable`
4 | > :warning: This rule is **deprecated** in favour of [S1181](https://rules.sonarsource.com/java/RSPEC-1181). 5 | 6 | ----- 7 | 8 | 9 | Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as 10 | OutOfMemoryError that should be exposed and managed separately. 11 | -------------------------------------------------------------------------------- /docs/rules/AvoidConstantsInterface.md: -------------------------------------------------------------------------------- 1 | # AvoidConstantsInterface 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidConstantsInterface`
4 | > :warning: This rule is **deprecated** in favour of [S1214](https://rules.sonarsource.com/java/RSPEC-1214). 5 | 6 | ----- 7 | 8 | 9 |

10 | Avoid constants in interfaces. Interfaces should define types, constants are implementation details better placed in 11 | classes or enums. 12 |

13 |

14 | See Effective Java, item 19. 15 |

16 | -------------------------------------------------------------------------------- /docs/rules/AvoidDeeplyNestedIfStmts.md: -------------------------------------------------------------------------------- 1 | # AvoidDeeplyNestedIfStmts 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidDeeplyNestedIfStmts`
4 | > :warning: This rule is **deprecated** in favour of [S134](https://rules.sonarsource.com/java/RSPEC-134). 5 | 6 | ----- 7 | 8 | 9 | Avoid creating deeply nested if-then statements since they are harder to read and error-prone to maintain. 10 | -------------------------------------------------------------------------------- /docs/rules/AvoidEnumAsIdentifier.md: -------------------------------------------------------------------------------- 1 | # AvoidEnumAsIdentifier 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidEnumAsIdentifier`
4 | > :warning: This rule is **deprecated** in favour of [S1190](https://rules.sonarsource.com/java/RSPEC-1190). 5 | 6 | ----- 7 | 8 | Finds all places 'enum' is used as an identifier is used. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidFinalLocalVariable.md: -------------------------------------------------------------------------------- 1 | # AvoidFinalLocalVariable 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidFinalLocalVariable`
4 | 5 | 6 | ----- 7 | 8 | Avoid using final local variables, turn them into fields. Example : 9 |
10 | public class MyClass {
11 |     public void foo() {
12 |         final String finalLocalVariable;
13 |     }
14 | }
15 |   
16 | -------------------------------------------------------------------------------- /docs/rules/AvoidInstanceofChecksInCatchClause.md: -------------------------------------------------------------------------------- 1 | # AvoidInstanceofChecksInCatchClause 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidInstanceofChecksInCatchClause`
4 | > :warning: This rule is **deprecated** in favour of [S1193](https://rules.sonarsource.com/java/RSPEC-1193). 5 | 6 | ----- 7 | 8 | Each caught exception type should be handled in its own catch clause. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidInstantiatingObjectsInLoops.md: -------------------------------------------------------------------------------- 1 | # AvoidInstantiatingObjectsInLoops 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidInstantiatingObjectsInLoops`
4 | 5 | 6 | ----- 7 | 8 | Detects when a new object is created inside a loop 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidLiteralsInIfCondition.md: -------------------------------------------------------------------------------- 1 | # AvoidLiteralsInIfCondition 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidLiteralsInIfCondition`
4 | > :warning: This rule is **deprecated** in favour of [S109](https://rules.sonarsource.com/java/RSPEC-109). 5 | 6 | ----- 7 | 8 | Avoid using hard coded literals in conditional statements, declare those as static variables or private members. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidLosingExceptionInformation.md: -------------------------------------------------------------------------------- 1 | # AvoidLosingExceptionInformation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidLosingExceptionInformation`
4 | > :warning: This rule is **deprecated** in favour of [S1166](https://rules.sonarsource.com/java/RSPEC-1166). 5 | 6 | ----- 7 | 8 | Statements in a catch block that invoke accessors on the exception without using the information only add to code size. Either remove the invocation, or use the return result. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidPrintStackTrace.md: -------------------------------------------------------------------------------- 1 | # AvoidPrintStackTrace 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidPrintStackTrace`
4 | > :warning: This rule is **deprecated** in favour of [S1148](https://rules.sonarsource.com/java/RSPEC-1148). 5 | 6 | ----- 7 | 8 | Avoid printStackTrace(); use a logger call instead. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidProtectedFieldInFinalClass.md: -------------------------------------------------------------------------------- 1 | # AvoidProtectedFieldInFinalClass 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidProtectedFieldInFinalClass`
4 | > :warning: This rule is **deprecated** in favour of [S2156](https://rules.sonarsource.com/java/RSPEC-2156). 5 | 6 | ----- 7 | 8 | Do not use protected fields in final classes since they cannot be subclassed. Clarify your intent by using private or package access modifiers instead. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidReassigningParameters.md: -------------------------------------------------------------------------------- 1 | # AvoidReassigningParameters 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidReassigningParameters`
4 | > :warning: This rule is **deprecated** in favour of [S1226](https://rules.sonarsource.com/java/RSPEC-1226). 5 | 6 | ----- 7 | 8 | Reassigning values to parameters is a questionable practice. Use a temporary local variable instead. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidRethrowingException.md: -------------------------------------------------------------------------------- 1 | # AvoidRethrowingException 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidRethrowingException`
4 | > :warning: This rule is **deprecated** in favour of [S1166](https://rules.sonarsource.com/java/RSPEC-1166). 5 | 6 | ----- 7 | 8 | Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidStringBufferField.md: -------------------------------------------------------------------------------- 1 | # AvoidStringBufferField 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidStringBufferField`
4 | > :warning: This rule is **deprecated** in favour of [S1149](https://rules.sonarsource.com/java/RSPEC-1149). 5 | 6 | ----- 7 | 8 | StringBuffers can grow quite a lot, and so may become a source of memory leak (if the owning class has a long life time). Example : 9 |
10 | class Foo {
11 |   private StringBuffer memoryLeak;
12 | }
13 | 
14 | -------------------------------------------------------------------------------- /docs/rules/AvoidSynchronizedAtMethodLevel.md: -------------------------------------------------------------------------------- 1 | # AvoidSynchronizedAtMethodLevel 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidSynchronizedAtMethodLevel`
4 | 5 | 6 | ----- 7 | 8 | Method level synchronization can backfire when new code is added to the method. Block-level synchronization helps to ensure that only the code that needs synchronization gets it. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidThreadGroup.md: -------------------------------------------------------------------------------- 1 | # AvoidThreadGroup 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidThreadGroup`
4 | 5 | 6 | ----- 7 | 8 | Avoid using ThreadGroup; although it is intended to be used in a threaded environment it contains methods that are not thread safe. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidThrowingNullPointerException.md: -------------------------------------------------------------------------------- 1 | # AvoidThrowingNullPointerException 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidThrowingNullPointerException`
4 | > :warning: This rule is **deprecated** in favour of [S1695](https://rules.sonarsource.com/java/RSPEC-1695). 5 | 6 | ----- 7 | 8 | Avoid throwing a NullPointerException - it's confusing because most people will assume that the virtual machine threw it. Consider using an IllegalArgumentException instead; this will be clearly seen as a programmer-initiated exception. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidThrowingRawExceptionTypes.md: -------------------------------------------------------------------------------- 1 | # AvoidThrowingRawExceptionTypes 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidThrowingRawExceptionTypes`
4 | > :warning: This rule is **deprecated** in favour of [S112](https://rules.sonarsource.com/java/RSPEC-112). 5 | 6 | ----- 7 | 8 |

9 | Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable, Exception, or Error, use 10 | a subclassed exception or error instead. 11 |

12 | -------------------------------------------------------------------------------- /docs/rules/AvoidUsingHardCodedIP.md: -------------------------------------------------------------------------------- 1 | # AvoidUsingHardCodedIP 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidUsingHardCodedIP`
4 | > :warning: This rule is **deprecated** in favour of [S1313](https://rules.sonarsource.com/java/RSPEC-1313). 5 | 6 | ----- 7 | 8 | An application with hard-coded IP addresses can become impossible to deploy in some cases. Externalizing IP addresses is preferable. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidUsingNativeCode.md: -------------------------------------------------------------------------------- 1 | # AvoidUsingNativeCode 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidUsingNativeCode`
4 | 5 | 6 | ----- 7 | 8 | As JVM and Java language offer already many help in creating application, it should be very rare to have to rely on non-java code. Even though, it is rare to actually have to use Java Native Interface (JNI). As the use of JNI make application less portable, and harder to maintain, it is not recommended. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidUsingOctalValues.md: -------------------------------------------------------------------------------- 1 | # AvoidUsingOctalValues 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidUsingOctalValues`
4 | > :warning: This rule is **deprecated** in favour of [S1314](https://rules.sonarsource.com/java/RSPEC-1314). 5 | 6 | ----- 7 | 8 | Integer literals should not start with zero. Zero means that the rest of literal will be interpreted as an octal value. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidUsingShortType.md: -------------------------------------------------------------------------------- 1 | # AvoidUsingShortType 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidUsingShortType`
4 | 5 | 6 | ----- 7 | 8 | Java uses the short type to reduce memory usage, not to optimize calculation. On the contrary, the JVM does not have arithmetic capabilities with the type short. So, the P-code must convert the short into int, then do the proper calculation and then again, convert int to short. So, use of the short type may have a great effect on memory usage. 9 | -------------------------------------------------------------------------------- /docs/rules/AvoidUsingVolatile.md: -------------------------------------------------------------------------------- 1 | # AvoidUsingVolatile 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:AvoidUsingVolatile`
4 | 5 | 6 | ----- 7 | 8 | Use of the keyword "volatile" is general used to fine tune a Java application, and therefore, requires a good expertise of the Java Memory Model. Morover, its range of action is somewhat misknown. Therefore, the volatile keyword should not be used for maintenance purpose and portability. 9 | -------------------------------------------------------------------------------- /docs/rules/BadComparison.md: -------------------------------------------------------------------------------- 1 | # BadComparison 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:BadComparison`
4 | 5 | 6 | ----- 7 | 8 | Avoid equality comparisons with Double.NaN - these are likely to be logic errors. 9 | -------------------------------------------------------------------------------- /docs/rules/BeanMembersShouldSerialize.md: -------------------------------------------------------------------------------- 1 | # BeanMembersShouldSerialize 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:BeanMembersShouldSerialize`
4 | 5 | 6 | ----- 7 | 8 | If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable. Member variables need to be marked as transient, static, or have accessor methods in the class. Marking variables as transient is the safest and easiest modification. Accessor methods should follow the Java naming conventions, i.e.if you have a variable foo, you should provide getFoo and setFoo methods. 9 | -------------------------------------------------------------------------------- /docs/rules/BigIntegerInstantiation.md: -------------------------------------------------------------------------------- 1 | # BigIntegerInstantiation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:BigIntegerInstantiation`
4 | 5 | 6 | ----- 7 | 8 | Don't create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) and for 1.5 on, BigInteger.TEN and BigDecimal (BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN) 9 | -------------------------------------------------------------------------------- /docs/rules/BooleanGetMethodName.md: -------------------------------------------------------------------------------- 1 | # BooleanGetMethodName 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:BooleanGetMethodName`
4 | 5 | 6 | ----- 7 | 8 | Looks for methods named "getX()" with "boolean" as the return type. The convention is to name these methods "isX()". 9 | -------------------------------------------------------------------------------- /docs/rules/BooleanInstantiation.md: -------------------------------------------------------------------------------- 1 | # BooleanInstantiation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:BooleanInstantiation`
4 | 5 | 6 | ----- 7 | 8 | Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boolean.valueOf() instead. 9 | -------------------------------------------------------------------------------- /docs/rules/BrokenNullCheck.md: -------------------------------------------------------------------------------- 1 | # BrokenNullCheck 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:BrokenNullCheck`
4 | > :warning: This rule is **deprecated** in favour of [S1697](https://rules.sonarsource.com/java/RSPEC-1697). 5 | 6 | ----- 7 | 8 | The null check is broken since it will throw a Nullpointer itself. The reason is that a method is called on the object when it is null. It is likely that you used || instead of && or vice versa. 9 | -------------------------------------------------------------------------------- /docs/rules/ByteInstantiation.md: -------------------------------------------------------------------------------- 1 | # ByteInstantiation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ByteInstantiation`
4 | 5 | 6 | ----- 7 | 8 | In JDK 1.5, calling new Byte() causes memory allocation. Byte.valueOf() is more memory friendly. Example : 9 |
10 | public class Foo {
11 | private Byte i = new Byte(0); // change to Byte i =
12 | Byte.valueOf(0);
13 | }
14 | 
15 | -------------------------------------------------------------------------------- /docs/rules/CallSuperFirst.md: -------------------------------------------------------------------------------- 1 | # CallSuperFirst 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CallSuperFirst`
4 | 5 | 6 | ----- 7 | 8 | Super should be called at the start of the method. Example : 9 |
10 | public class DummyActivity extends Activity {
11 |   public void onCreate(Bundle bundle) {
12 |     // missing call to super.onCreate(bundle)
13 |     foo();
14 |   }
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /docs/rules/CallSuperInConstructor.md: -------------------------------------------------------------------------------- 1 | # CallSuperInConstructor 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CallSuperInConstructor`
4 | 5 | 6 | ----- 7 | 8 | It is a good practice to call super() in a constructor. If super() is not called but another constructor (such as an overloaded constructor) is called, this rule will not report it. 9 | -------------------------------------------------------------------------------- /docs/rules/CallSuperLast.md: -------------------------------------------------------------------------------- 1 | # CallSuperLast 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CallSuperLast`
4 | 5 | 6 | ----- 7 | 8 | Super should be called at the end of the method. Example : 9 |
10 | public class DummyActivity extends Activity {
11 |   public void onPause() {
12 |     foo();
13 |     // missing call to super.onPause()
14 |   }
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /docs/rules/CheckResultSet.md: -------------------------------------------------------------------------------- 1 | # CheckResultSet 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CheckResultSet`
4 | 5 | 6 | ----- 7 | 8 | Always check the return of one of the navigation method (next,previous,first,last) of a ResultSet. Indeed, if the value return is "false", the developer should deal with it ! 9 | -------------------------------------------------------------------------------- /docs/rules/ClassCastExceptionWithToArray.md: -------------------------------------------------------------------------------- 1 | # ClassCastExceptionWithToArray 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ClassCastExceptionWithToArray`
4 | 5 | 6 | ----- 7 | 8 | if you need to get an array of a class from your Collection, you should pass an array of the desidered class as the parameter of the toArray method. Otherwise you will get a ClassCastException. 9 | -------------------------------------------------------------------------------- /docs/rules/ClassNamingConventions.md: -------------------------------------------------------------------------------- 1 | # ClassNamingConventions 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ClassNamingConventions`
4 | > :warning: This rule is **deprecated** in favour of [S101](https://rules.sonarsource.com/java/RSPEC-101), [S114](https://rules.sonarsource.com/java/RSPEC-114). 5 | 6 | ----- 7 | 8 |

9 | Class names should always begin with an upper case character. 10 |

11 | -------------------------------------------------------------------------------- /docs/rules/ClassWithOnlyPrivateConstructorsShouldBeFinal.md: -------------------------------------------------------------------------------- 1 | # ClassWithOnlyPrivateConstructorsShouldBeFinal 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ClassWithOnlyPrivateConstructorsShouldBeFinal`
4 | > :warning: This rule is **deprecated** in favour of [S2974](https://rules.sonarsource.com/java/RSPEC-2974). 5 | 6 | ----- 7 | 8 | A class with only private constructors should be final, unless the private constructor is called by a inner class. Example : 9 |
10 | public class Foo {  //Should be final
11 |     private Foo() { }
12 | }
13 | 
14 | -------------------------------------------------------------------------------- /docs/rules/CloneMethodMustImplementCloneable.md: -------------------------------------------------------------------------------- 1 | # CloneMethodMustImplementCloneable 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CloneMethodMustImplementCloneable`
4 | > :warning: This rule is **deprecated** in favour of [S1182](https://rules.sonarsource.com/java/RSPEC-1182). 5 | 6 | ----- 7 | 8 | The method clone() should only be implemented if the class implements the Cloneable interface with the exception of a final method that only throws CloneNotSupportedException. 9 | -------------------------------------------------------------------------------- /docs/rules/CloneThrowsCloneNotSupportedException.md: -------------------------------------------------------------------------------- 1 | # CloneThrowsCloneNotSupportedException 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CloneThrowsCloneNotSupportedException`
4 | > :warning: This rule is **deprecated** in favour of [S1182](https://rules.sonarsource.com/java/RSPEC-1182). 5 | 6 | ----- 7 | 8 | The method clone() should throw a CloneNotSupportedException. 9 | -------------------------------------------------------------------------------- /docs/rules/CloseResource.md: -------------------------------------------------------------------------------- 1 | # CloseResource 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CloseResource`
4 | > :warning: This rule is **deprecated** in favour of [S2095](https://rules.sonarsource.com/java/RSPEC-2095). 5 | 6 | ----- 7 | 8 | Ensure that resources (like Connection, Statement, and ResultSet objects) are always closed after use. It does this by looking for code patterned like : 9 |
10 | Connection c = openConnection();
11 | try {
12 |   // do stuff, and maybe catch something
13 | } finally {
14 |   c.close();
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /docs/rules/CollapsibleIfStatements.md: -------------------------------------------------------------------------------- 1 | # CollapsibleIfStatements 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CollapsibleIfStatements`
4 | > :warning: This rule is **deprecated** in favour of [S1066](https://rules.sonarsource.com/java/RSPEC-1066). 5 | 6 | ----- 7 | 8 | Sometimes two 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator. 9 | -------------------------------------------------------------------------------- /docs/rules/CommentContent.md: -------------------------------------------------------------------------------- 1 | # CommentContent 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CommentContent`
4 | 5 | 6 | ----- 7 | 8 | A rule for the politically correct... we don't want to offend anyone. Example: 9 |
10 | // OMG, this is horrible, Bob is an idiot !!!
11 | 
12 | -------------------------------------------------------------------------------- /docs/rules/CommentRequired.md: -------------------------------------------------------------------------------- 1 | # CommentRequired 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CommentRequired`
4 | 5 | 6 | ----- 7 | 8 | Denotes whether comments are required (or unwanted) for specific language elements. Example: 9 |
10 | /**
11 | * 
12 | *
13 | * @author George Bush
14 | */
15 | 
16 | -------------------------------------------------------------------------------- /docs/rules/CommentSize.md: -------------------------------------------------------------------------------- 1 | # CommentSize 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CommentSize`
4 | 5 | 6 | ----- 7 | 8 | Determines whether the dimensions of non-header comments found are within the specified limits. Example: 9 |
10 | /**
11 | *
12 | * too many lines!
13 | *
14 | *
15 | *
16 | *
17 | *
18 | *
19 | *
20 | *
21 | *
22 | *
23 | *
24 | *
25 | */
26 | 
27 | -------------------------------------------------------------------------------- /docs/rules/CompareObjectsWithEquals.md: -------------------------------------------------------------------------------- 1 | # CompareObjectsWithEquals 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CompareObjectsWithEquals`
4 | > :warning: This rule is **deprecated** in favour of [S1698](https://rules.sonarsource.com/java/RSPEC-1698). 5 | 6 | ----- 7 | 8 | Use equals() to compare object references; avoid comparing them with ==. 9 | -------------------------------------------------------------------------------- /docs/rules/ConfusingTernary.md: -------------------------------------------------------------------------------- 1 | # ConfusingTernary 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ConfusingTernary`
4 | 5 | 6 | ----- 7 | 8 | In an if expression with an else clause, avoid negation in the test. For example, rephrase: if (x != y) diff(); else same(); as: if (x == y) same(); else diff(); Most if (x != y) cases without an else are often return cases, so consistent use of this rule makes the code easier to read. Also, this resolves trivial ordering problems, such as does the error case go first? or does the common case go first?. 9 | -------------------------------------------------------------------------------- /docs/rules/ConsecutiveLiteralAppends.md: -------------------------------------------------------------------------------- 1 | # ConsecutiveLiteralAppends 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ConsecutiveLiteralAppends`
4 | 5 | 6 | ----- 7 | 8 | Consecutively calling StringBuffer.append with String literals 9 | -------------------------------------------------------------------------------- /docs/rules/CouplingBetweenObjects.md: -------------------------------------------------------------------------------- 1 | # CouplingBetweenObjects 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:CouplingBetweenObjects`
4 | > :warning: This rule is **deprecated** in favour of [S1200](https://rules.sonarsource.com/java/RSPEC-1200). 5 | 6 | ----- 7 | 8 | This rule counts unique attributes, local variables and return types within an object. A number higher than specified threshold can indicate a high degree of coupling. 9 | -------------------------------------------------------------------------------- /docs/rules/DefaultPackage.md: -------------------------------------------------------------------------------- 1 | # DefaultPackage 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:DefaultPackage`
4 | 5 | 6 | ----- 7 | 8 | Use explicit scoping instead of the default package private level. 9 | -------------------------------------------------------------------------------- /docs/rules/DoNotCallSystemExit.md: -------------------------------------------------------------------------------- 1 | # DoNotCallSystemExit 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:DoNotCallSystemExit`
4 | > :warning: This rule is **deprecated** in favour of [S1147](https://rules.sonarsource.com/java/RSPEC-1147). 5 | 6 | ----- 7 | 8 | Web applications should not call System.exit(), since only the web container or the application server should stop the JVM. 9 | -------------------------------------------------------------------------------- /docs/rules/DoNotExtendJavaLangError.md: -------------------------------------------------------------------------------- 1 | # DoNotExtendJavaLangError 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:DoNotExtendJavaLangError`
4 | > :warning: This rule is **deprecated** in favour of [S1194](https://rules.sonarsource.com/java/RSPEC-1194). 5 | 6 | ----- 7 | 8 | Errors are system exceptions. Do not extend them. 9 | -------------------------------------------------------------------------------- /docs/rules/DoNotHardCodeSDCard.md: -------------------------------------------------------------------------------- 1 | # DoNotHardCodeSDCard 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:DoNotHardCodeSDCard`
4 | 5 | 6 | ----- 7 | 8 | Use Environment.getExternalStorageDirectory() instead of "/sdcard". 9 | -------------------------------------------------------------------------------- /docs/rules/DoNotUseThreads.md: -------------------------------------------------------------------------------- 1 | # DoNotUseThreads 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:DoNotUseThreads`
4 | 5 | 6 | ----- 7 | 8 | The J2EE specification explicitly forbid use of threads. 9 | -------------------------------------------------------------------------------- /docs/rules/DontCallThreadRun.md: -------------------------------------------------------------------------------- 1 | # DontCallThreadRun 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:DontCallThreadRun`
4 | > :warning: This rule is **deprecated** in favour of [S1217](https://rules.sonarsource.com/java/RSPEC-1217). 5 | 6 | ----- 7 | 8 | Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior. 9 | -------------------------------------------------------------------------------- /docs/rules/DontImportJavaLang.md: -------------------------------------------------------------------------------- 1 | # DontImportJavaLang 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:DontImportJavaLang`
4 | > :warning: This rule is **deprecated** in favour of `java:UselessImportCheck`. 5 | 6 | ----- 7 | 8 | Avoid importing anything from the package 'java.lang'. These classes are automatically imported (JLS 7.5.3). 9 | -------------------------------------------------------------------------------- /docs/rules/DontImportSun.md: -------------------------------------------------------------------------------- 1 | # DontImportSun 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:DontImportSun`
4 | > :warning: This rule is **deprecated** in favour of [S1191](https://rules.sonarsource.com/java/RSPEC-1191). 5 | 6 | ----- 7 | 8 | Avoid importing anything from the 'sun.*' packages. These packages are not portable and are likely to change. 9 | -------------------------------------------------------------------------------- /docs/rules/DuplicateImports.md: -------------------------------------------------------------------------------- 1 | # DuplicateImports 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:DuplicateImports`
4 | > :warning: This rule is **deprecated** in favour of `java:UselessImportCheck`. 5 | 6 | ----- 7 | 8 | Avoid duplicate import statements. 9 | -------------------------------------------------------------------------------- /docs/rules/EmptyCatchBlock.md: -------------------------------------------------------------------------------- 1 | # EmptyCatchBlock 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyCatchBlock`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 |

9 | Empty Catch Block finds instances where an exception is caught, but nothing is done. In most circumstances, this 10 | swallows an exception which should either be acted on or reported. 11 |

12 | -------------------------------------------------------------------------------- /docs/rules/EmptyFinalizer.md: -------------------------------------------------------------------------------- 1 | # EmptyFinalizer 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyFinalizer`
4 | > :warning: This rule is **deprecated** in favour of [S1186](https://rules.sonarsource.com/java/RSPEC-1186). 5 | 6 | ----- 7 | 8 |

If the finalize() method is empty, then it does not need to exist.

9 | -------------------------------------------------------------------------------- /docs/rules/EmptyFinallyBlock.md: -------------------------------------------------------------------------------- 1 | # EmptyFinallyBlock 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyFinallyBlock`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 |

9 | Avoid empty finally blocks - these can be deleted. 10 |

11 | -------------------------------------------------------------------------------- /docs/rules/EmptyIfStmt.md: -------------------------------------------------------------------------------- 1 | # EmptyIfStmt 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyIfStmt`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 |

9 | Empty If Statement finds instances where a condition is checked but nothing is done about it. 10 |

11 | -------------------------------------------------------------------------------- /docs/rules/EmptyInitializer.md: -------------------------------------------------------------------------------- 1 | # EmptyInitializer 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyInitializer`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 | An empty initializer was found. Example : 9 |
10 | public class Foo {
11 | 
12 |    static {} // Why ?
13 | 
14 |    {} // Again, why ?
15 | 
16 | }
17 | 
18 | -------------------------------------------------------------------------------- /docs/rules/EmptyStatementBlock.md: -------------------------------------------------------------------------------- 1 | # EmptyStatementBlock 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyStatementBlock`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 | Empty block statements serve no purpose and should be removed. Example: 9 |
10 | public class Foo {
11 | 
12 |    private int _bar;
13 | 
14 |    public void setBar(int bar) {
15 |       { _bar = bar; } // Why not?
16 |       {} // But remove this.
17 |    }
18 | 
19 | }
20 | 
21 | -------------------------------------------------------------------------------- /docs/rules/EmptyStatementNotInLoop.md: -------------------------------------------------------------------------------- 1 | # EmptyStatementNotInLoop 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyStatementNotInLoop`
4 | > :warning: This rule is **deprecated** in favour of `java:EmptyStatementUsageCheck`. 5 | 6 | ----- 7 | 8 | An empty statement (aka a semicolon by itself) that is not used as the sole body of a for loop or while loop is probably a bug. It could also be a double semicolon, which is useless and should be removed. 9 | -------------------------------------------------------------------------------- /docs/rules/EmptyStaticInitializer.md: -------------------------------------------------------------------------------- 1 | # EmptyStaticInitializer 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyStaticInitializer`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 | An empty static initializer was found. 9 | -------------------------------------------------------------------------------- /docs/rules/EmptySwitchStatements.md: -------------------------------------------------------------------------------- 1 | # EmptySwitchStatements 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptySwitchStatements`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 | Avoid empty switch statements. 9 | -------------------------------------------------------------------------------- /docs/rules/EmptySynchronizedBlock.md: -------------------------------------------------------------------------------- 1 | # EmptySynchronizedBlock 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptySynchronizedBlock`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 | Avoid empty synchronized blocks - they're useless. 9 | -------------------------------------------------------------------------------- /docs/rules/EmptyTryBlock.md: -------------------------------------------------------------------------------- 1 | # EmptyTryBlock 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyTryBlock`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 | Avoid empty try blocks - what's the point? 9 | -------------------------------------------------------------------------------- /docs/rules/EmptyWhileStmt.md: -------------------------------------------------------------------------------- 1 | # EmptyWhileStmt 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EmptyWhileStmt`
4 | > :warning: This rule is **deprecated** in favour of [S108](https://rules.sonarsource.com/java/RSPEC-108). 5 | 6 | ----- 7 | 8 | Empty While Statement finds all instances where a while statement does nothing. If it is a timing loop, then you should use Thread.sleep() for it; if it's a while loop that does a lot in the exit expression, rewrite it to make it clearer. 9 | -------------------------------------------------------------------------------- /docs/rules/EqualsNull.md: -------------------------------------------------------------------------------- 1 | # EqualsNull 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:EqualsNull`
4 | > :warning: This rule is **deprecated** in favour of [S2159](https://rules.sonarsource.com/java/RSPEC-2159). 5 | 6 | ----- 7 | 8 | Inexperienced programmers sometimes confuse comparison concepts and use equals() to compare to null. 9 | -------------------------------------------------------------------------------- /docs/rules/ExceptionAsFlowControl.md: -------------------------------------------------------------------------------- 1 | # ExceptionAsFlowControl 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ExceptionAsFlowControl`
4 | > :warning: This rule is **deprecated** in favour of [S1141](https://rules.sonarsource.com/java/RSPEC-1141). 5 | 6 | ----- 7 | 8 | Using Exceptions as flow control leads to GOTOish code and obscures true exceptions when debugging. 9 | -------------------------------------------------------------------------------- /docs/rules/ExcessiveClassLength.md: -------------------------------------------------------------------------------- 1 | # ExcessiveClassLength 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ExcessiveClassLength`
4 | > :warning: This rule is **deprecated** in favour of [S1448](https://rules.sonarsource.com/java/RSPEC-1448). 5 | 6 | ----- 7 | 8 | Long Class files are indications that the class may be trying to do too much. Try to break it down, and reduce the size to something manageable. 9 | -------------------------------------------------------------------------------- /docs/rules/ExcessiveImports.md: -------------------------------------------------------------------------------- 1 | # ExcessiveImports 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ExcessiveImports`
4 | > :warning: This rule is **deprecated** in favour of [S1200](https://rules.sonarsource.com/java/RSPEC-1200). 5 | 6 | ----- 7 | 8 | A high number of imports can indicate a high degree of coupling within an object. Rule counts the number of unique imports and reports a violation if the count is above the user defined threshold. 9 | -------------------------------------------------------------------------------- /docs/rules/ExcessiveMethodLength.md: -------------------------------------------------------------------------------- 1 | # ExcessiveMethodLength 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ExcessiveMethodLength`
4 | > :warning: This rule is **deprecated** in favour of [S138](https://rules.sonarsource.com/java/RSPEC-138). 5 | 6 | ----- 7 | 8 | Violations of this rule usually indicate that the method is doing too much. Try to reduce the method size by creating helper methods and removing any copy/pasted code. 9 | -------------------------------------------------------------------------------- /docs/rules/ExcessiveParameterList.md: -------------------------------------------------------------------------------- 1 | # ExcessiveParameterList 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ExcessiveParameterList`
4 | > :warning: This rule is **deprecated** in favour of [S107](https://rules.sonarsource.com/java/RSPEC-107). 5 | 6 | ----- 7 | 8 |

9 | Long parameter lists can indicate that a new object should be created to wrap the numerous parameters. Basically, try 10 | to group the parameters together. 11 |

12 | -------------------------------------------------------------------------------- /docs/rules/ExcessivePublicCount.md: -------------------------------------------------------------------------------- 1 | # ExcessivePublicCount 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ExcessivePublicCount`
4 | > :warning: This rule is **deprecated** in favour of [S1448](https://rules.sonarsource.com/java/RSPEC-1448). 5 | 6 | ----- 7 | 8 | A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it. 9 | -------------------------------------------------------------------------------- /docs/rules/ExtendsObject.md: -------------------------------------------------------------------------------- 1 | # ExtendsObject 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ExtendsObject`
4 | > :warning: This rule is **deprecated** in favour of [S1939](https://rules.sonarsource.com/java/RSPEC-1939). 5 | 6 | ----- 7 | 8 | No need to explicitly extend Object. Example: 9 |
10 | public class Foo extends Object { // not required
11 | }
12 | 
13 | -------------------------------------------------------------------------------- /docs/rules/FinalFieldCouldBeStatic.md: -------------------------------------------------------------------------------- 1 | # FinalFieldCouldBeStatic 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:FinalFieldCouldBeStatic`
4 | > :warning: This rule is **deprecated** in favour of [S1170](https://rules.sonarsource.com/java/RSPEC-1170). 5 | 6 | ----- 7 | 8 | If a final field is assigned to a compile-time constant, it could be made static, thus saving overhead in each object at runtime. 9 | -------------------------------------------------------------------------------- /docs/rules/FinalizeDoesNotCallSuperFinalize.md: -------------------------------------------------------------------------------- 1 | # FinalizeDoesNotCallSuperFinalize 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:FinalizeDoesNotCallSuperFinalize`
4 | > :warning: This rule is **deprecated** in favour of `java:ObjectFinalizeOverridenCallsSuperFinalizeCheck`. 5 | 6 | ----- 7 | 8 | If the finalize() is implemented, its last action should be to call super.finalize. 9 | -------------------------------------------------------------------------------- /docs/rules/FinalizeOnlyCallsSuperFinalize.md: -------------------------------------------------------------------------------- 1 | # FinalizeOnlyCallsSuperFinalize 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:FinalizeOnlyCallsSuperFinalize`
4 | > :warning: This rule is **deprecated** in favour of [S1185](https://rules.sonarsource.com/java/RSPEC-1185). 5 | 6 | ----- 7 | 8 | If the finalize() is implemented, it should do something besides just calling super.finalize(). 9 | -------------------------------------------------------------------------------- /docs/rules/FinalizeOverloaded.md: -------------------------------------------------------------------------------- 1 | # FinalizeOverloaded 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:FinalizeOverloaded`
4 | > :warning: This rule is **deprecated** in favour of [S1175](https://rules.sonarsource.com/java/RSPEC-1175). 5 | 6 | ----- 7 | 8 | Methods named finalize() should not have parameters. It is confusing and probably a bug to overload finalize(). It will not be called by the VM. 9 | -------------------------------------------------------------------------------- /docs/rules/FinalizeShouldBeProtected.md: -------------------------------------------------------------------------------- 1 | # FinalizeShouldBeProtected 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:FinalizeShouldBeProtected`
4 | > :warning: This rule is **deprecated** in favour of [S1174](https://rules.sonarsource.com/java/RSPEC-1174). 5 | 6 | ----- 7 | 8 | If you override finalize(), make it protected. If you make it public, other classes may call it. 9 | -------------------------------------------------------------------------------- /docs/rules/ForLoopShouldBeWhileLoop.md: -------------------------------------------------------------------------------- 1 | # ForLoopShouldBeWhileLoop 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ForLoopShouldBeWhileLoop`
4 | > :warning: This rule is **deprecated** in favour of [S1264](https://rules.sonarsource.com/java/RSPEC-1264). 5 | 6 | ----- 7 | 8 | Some for loops can be simplified to while loops - this makes them more concise. 9 | -------------------------------------------------------------------------------- /docs/rules/ForLoopsMustUseBraces.md: -------------------------------------------------------------------------------- 1 | # ForLoopsMustUseBraces 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ForLoopsMustUseBraces`
4 | > :warning: This rule is **deprecated** in favour of [S121](https://rules.sonarsource.com/java/RSPEC-121). 5 | 6 | ----- 7 | 8 |

9 | Avoid using 'for' statements without using curly braces, like for (int i=0; i<42;i++) foo(); 10 |

11 | -------------------------------------------------------------------------------- /docs/rules/GenericsNaming.md: -------------------------------------------------------------------------------- 1 | # GenericsNaming 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:GenericsNaming`
4 | > :warning: This rule is **deprecated** in favour of [S119](https://rules.sonarsource.com/java/RSPEC-119). 5 | 6 | ----- 7 | 8 | Generics names should be a one letter long and upper case. 9 | -------------------------------------------------------------------------------- /docs/rules/GuardDebugLogging.md: -------------------------------------------------------------------------------- 1 | # GuardDebugLogging 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:GuardDebugLogging`
4 | 5 | 6 | ----- 7 | 8 | When log messages are composed by concatenating strings, the whole section should be guarded by a isDebugEnabled() check to avoid performance and memory issues. 9 | -------------------------------------------------------------------------------- /docs/rules/GuardLogStatement.md: -------------------------------------------------------------------------------- 1 | # GuardLogStatement 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:GuardLogStatement`
4 | 5 | 6 | ----- 7 | 8 | Whenever using a log level, one should check if the loglevel is actually enabled, or 9 | otherwise skip the associate String creation and manipulation. Example: 10 |
11 | // Add this for performance
12 | if (log.isDebugEnabled() { ...
13 |   log.debug("This happens");
14 | 
15 | -------------------------------------------------------------------------------- /docs/rules/GuardLogStatementJavaUtil.md: -------------------------------------------------------------------------------- 1 | # GuardLogStatementJavaUtil 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:GuardLogStatementJavaUtil`
4 | 5 | 6 | ----- 7 | 8 | Whenever using a log level, one should check if the loglevel is actually enabled, or 9 | otherwise skip the associate String creation and manipulation. Example: 10 |
11 | // Add this for performance
12 | if (log.isLoggable(Level.FINE)) { ...
13 |   log.fine("This happens");
14 | 
15 | -------------------------------------------------------------------------------- /docs/rules/IdempotentOperations.md: -------------------------------------------------------------------------------- 1 | # IdempotentOperations 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:IdempotentOperations`
4 | > :warning: This rule is **deprecated** in favour of [S1656](https://rules.sonarsource.com/java/RSPEC-1656). 5 | 6 | ----- 7 | 8 | Avoid idempotent operations - they are have no effect. Example :
int x = 2;
x = x;
9 | -------------------------------------------------------------------------------- /docs/rules/IfElseStmtsMustUseBraces.md: -------------------------------------------------------------------------------- 1 | # IfElseStmtsMustUseBraces 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:IfElseStmtsMustUseBraces`
4 | > :warning: This rule is **deprecated** in favour of [S121](https://rules.sonarsource.com/java/RSPEC-121). 5 | 6 | ----- 7 | 8 |

9 | Avoid using if..else statements without using curly braces. 10 |

11 | -------------------------------------------------------------------------------- /docs/rules/IfStmtsMustUseBraces.md: -------------------------------------------------------------------------------- 1 | # IfStmtsMustUseBraces 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:IfStmtsMustUseBraces`
4 | > :warning: This rule is **deprecated** in favour of [S121](https://rules.sonarsource.com/java/RSPEC-121). 5 | 6 | ----- 7 | 8 |

9 | Avoid using if statements without using curly braces. 10 |

11 | -------------------------------------------------------------------------------- /docs/rules/ImmutableField.md: -------------------------------------------------------------------------------- 1 | # ImmutableField 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ImmutableField`
4 | 5 | 6 | ----- 7 | 8 | Identifies private fields whose values never change once they are initialized either in the declaration of the field or by a constructor. This aids in converting existing classes to immutable classes. 9 | -------------------------------------------------------------------------------- /docs/rules/ImportFromSamePackage.md: -------------------------------------------------------------------------------- 1 | # ImportFromSamePackage 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ImportFromSamePackage`
4 | > :warning: This rule is **deprecated** in favour of `java:UselessImportCheck`. 5 | 6 | ----- 7 | 8 | No need to import a type that lives in the same package. 9 | -------------------------------------------------------------------------------- /docs/rules/InefficientEmptyStringCheck.md: -------------------------------------------------------------------------------- 1 | # InefficientEmptyStringCheck 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:InefficientEmptyStringCheck`
4 | 5 | 6 | ----- 7 | 8 | String.trim().length() is an inefficient way to check if a String is really empty, as it creates a new String object just to check its size. Consider creating a static function that loops through a string, checking Character.isWhitespace() on each character and returning false if a non-whitespace character is found. 9 | -------------------------------------------------------------------------------- /docs/rules/InefficientStringBuffering.md: -------------------------------------------------------------------------------- 1 | # InefficientStringBuffering 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:InefficientStringBuffering`
4 | 5 | 6 | ----- 7 | 8 | Avoid concatenating non literals in a StringBuffer constructor or append(). 9 | -------------------------------------------------------------------------------- /docs/rules/InstantiationToGetClass.md: -------------------------------------------------------------------------------- 1 | # InstantiationToGetClass 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:InstantiationToGetClass`
4 | > :warning: This rule is **deprecated** in favour of [S2133](https://rules.sonarsource.com/java/RSPEC-2133). 5 | 6 | ----- 7 | 8 | Avoid instantiating an object just to call getClass() on it; use the .class public member instead. Example : replace 9 | Class c = new String().getClass(); with Class c = String.class; 10 | -------------------------------------------------------------------------------- /docs/rules/IntegerInstantiation.md: -------------------------------------------------------------------------------- 1 | # IntegerInstantiation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:IntegerInstantiation`
4 | 5 | 6 | ----- 7 | 8 | In JDK 1.5, calling new Integer() causes memory allocation. Integer.valueOf() is more memory friendly. 9 | -------------------------------------------------------------------------------- /docs/rules/JUnitSpelling.md: -------------------------------------------------------------------------------- 1 | # JUnitSpelling 2 | **Category:** `pmd-unit-tests`
3 | **Rule Key:** `pmd-unit-tests:JUnitSpelling`
4 | 5 | 6 | ----- 7 | 8 | Some JUnit framework methods are easy to misspell. 9 |
10 | import junit.framework.*;
11 | 
12 | public class Foo extends TestCase {
13 |   public void setup() {} // violation, should be setUp()
14 |   public void TearDown() {} // violation, should be tearDown()
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /docs/rules/JUnitStaticSuite.md: -------------------------------------------------------------------------------- 1 | # JUnitStaticSuite 2 | **Category:** `pmd-unit-tests`
3 | **Rule Key:** `pmd-unit-tests:JUnitStaticSuite`
4 | 5 | 6 | ----- 7 | 8 | The suite() method in a JUnit test needs to be both public and static. 9 |
10 | import junit.framework.*;
11 | 
12 | public class Foo extends TestCase {
13 |   public void suite() {} // violation, should be static
14 |   private static void suite() {} // violation, should be public
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /docs/rules/LocalHomeNamingConvention.md: -------------------------------------------------------------------------------- 1 | # LocalHomeNamingConvention 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:LocalHomeNamingConvention`
4 | 5 | 6 | ----- 7 | 8 | The Local Home interface of a Session EJB should be suffixed by "LocalHome". 9 | -------------------------------------------------------------------------------- /docs/rules/LocalInterfaceSessionNamingConvention.md: -------------------------------------------------------------------------------- 1 | # LocalInterfaceSessionNamingConvention 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:LocalInterfaceSessionNamingConvention`
4 | 5 | 6 | ----- 7 | 8 | The Local Interface of a Session EJB should be suffixed by "Local". 9 | -------------------------------------------------------------------------------- /docs/rules/LocalVariableCouldBeFinal.md: -------------------------------------------------------------------------------- 1 | # LocalVariableCouldBeFinal 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:LocalVariableCouldBeFinal`
4 | 5 | 6 | ----- 7 | 8 | A local variable assigned only once can be declared final. Example : 9 |
10 | public class Bar {
11 |  public void foo () {
12 |   String a = "a"; //if a will not be assigned again it is better to do this:
13 |   final String b = "b";
14 |  }
15 | }
16 |   
17 | -------------------------------------------------------------------------------- /docs/rules/LoggerIsNotStaticFinal.md: -------------------------------------------------------------------------------- 1 | # LoggerIsNotStaticFinal 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:LoggerIsNotStaticFinal`
4 | > :warning: This rule is **deprecated** in favour of [S1312](https://rules.sonarsource.com/java/RSPEC-1312). 5 | 6 | ----- 7 | 8 | In most cases, the Logger can be declared static and final. 9 | -------------------------------------------------------------------------------- /docs/rules/LogicInversion.md: -------------------------------------------------------------------------------- 1 | # LogicInversion 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:LogicInversion`
4 | > :warning: This rule is **deprecated** in favour of [S1940](https://rules.sonarsource.com/java/RSPEC-1940). 5 | 6 | ----- 7 | 8 | Use opposite operator instead of negating the whole expression with a logic complement operator. Example: 9 |
10 | public boolean bar(int a, int b) {
11 | 
12 |   if (!(a == b)) // use !=
13 |     return false;
14 | 
15 |   if (!(a < b)) // use >=
16 |     return false;
17 | 
18 |   return true;
19 | }
20 | 
21 | -------------------------------------------------------------------------------- /docs/rules/LongInstantiation.md: -------------------------------------------------------------------------------- 1 | # LongInstantiation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:LongInstantiation`
4 | 5 | 6 | ----- 7 | 8 | In JDK 1.5, calling new Long() causes memory allocation. Long.valueOf() is more memory friendly. Example : 9 |
10 | public class Foo {
11 | private Long i = new Long(0); // change to Long i =
12 | Long.valueOf(0);
13 | }
14 |   
15 | -------------------------------------------------------------------------------- /docs/rules/LongVariable.md: -------------------------------------------------------------------------------- 1 | # LongVariable 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:LongVariable`
4 | > :warning: This rule is **deprecated** in favour of [S117](https://rules.sonarsource.com/java/RSPEC-117). 5 | 6 | ----- 7 | 8 | Detects when a field, formal or local variable is declared with a long name. 9 | -------------------------------------------------------------------------------- /docs/rules/LooseCoupling.md: -------------------------------------------------------------------------------- 1 | # LooseCoupling 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:LooseCoupling`
4 | > :warning: This rule is **deprecated** in favour of [S1319](https://rules.sonarsource.com/java/RSPEC-1319). 5 | 6 | ----- 7 | 8 | Avoid using implementation types (i.e., HashSet); use the interface (i.e, Set) instead 9 | -------------------------------------------------------------------------------- /docs/rules/MDBAndSessionBeanNamingConvention.md: -------------------------------------------------------------------------------- 1 | # MDBAndSessionBeanNamingConvention 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:MDBAndSessionBeanNamingConvention`
4 | 5 | 6 | ----- 7 | 8 | The EJB Specification state that any MessageDrivenBean or SessionBean should be suffixed by Bean. 9 | -------------------------------------------------------------------------------- /docs/rules/MethodArgumentCouldBeFinal.md: -------------------------------------------------------------------------------- 1 | # MethodArgumentCouldBeFinal 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:MethodArgumentCouldBeFinal`
4 | > :warning: This rule is **deprecated** in favour of [S1226](https://rules.sonarsource.com/java/RSPEC-1226). 5 | 6 | ----- 7 | 8 | A method argument that is never assigned can be declared final. 9 | -------------------------------------------------------------------------------- /docs/rules/MethodNamingConventions.md: -------------------------------------------------------------------------------- 1 | # MethodNamingConventions 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:MethodNamingConventions`
4 | > :warning: This rule is **deprecated** in favour of [S100](https://rules.sonarsource.com/java/RSPEC-100). 5 | 6 | ----- 7 | 8 | Method names should always begin with a lower case character, and should not contain underscores. Example : 9 |
10 | public class Foo {
11 |   public void fooStuff() {
12 |   }
13 | }
14 | 
15 | -------------------------------------------------------------------------------- /docs/rules/MethodReturnsInternalArray.md: -------------------------------------------------------------------------------- 1 | # MethodReturnsInternalArray 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:MethodReturnsInternalArray`
4 | > :warning: This rule is **deprecated** in favour of [S2384](https://rules.sonarsource.com/java/RSPEC-2384). 5 | 6 | ----- 7 | 8 | Exposing internal arrays directly allows the user to modify some code that could be critical. It is safer to return a copy of the array. 9 | -------------------------------------------------------------------------------- /docs/rules/MisleadingVariableName.md: -------------------------------------------------------------------------------- 1 | # MisleadingVariableName 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:MisleadingVariableName`
4 | > :warning: This rule is **deprecated** in favour of [S117](https://rules.sonarsource.com/java/RSPEC-117). 5 | 6 | ----- 7 | 8 | Detects when a non-field has a name starting with 'm_'. This usually indicates a field and thus is confusing. Example : 9 |
10 | public class Foo {
11 |   private int m_foo; // OK
12 |   public void bar(String m_baz) {  // Bad
13 |     int m_boz = 42; // Bad
14 |   }
15 | }
16 | 
17 | -------------------------------------------------------------------------------- /docs/rules/MissingBreakInSwitch.md: -------------------------------------------------------------------------------- 1 | # MissingBreakInSwitch 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:MissingBreakInSwitch`
4 | > :warning: This rule is **deprecated** in favour of [S128](https://rules.sonarsource.com/java/RSPEC-128). 5 | 6 | ----- 7 | 8 | A switch statement without an enclosed break statement may be a bug. 9 | -------------------------------------------------------------------------------- /docs/rules/MissingSerialVersionUID.md: -------------------------------------------------------------------------------- 1 | # MissingSerialVersionUID 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:MissingSerialVersionUID`
4 | > :warning: This rule is **deprecated** in favour of [S2057](https://rules.sonarsource.com/java/RSPEC-2057). 5 | 6 | ----- 7 | 8 | Classes that are serializable should provide a serialVersionUID field. 9 | -------------------------------------------------------------------------------- /docs/rules/MissingStaticMethodInNonInstantiatableClass.md: -------------------------------------------------------------------------------- 1 | # MissingStaticMethodInNonInstantiatableClass 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:MissingStaticMethodInNonInstantiatableClass`
4 | 5 | 6 | ----- 7 | 8 | A class that has private constructors and does not have any static methods or fields cannot be used. 9 | -------------------------------------------------------------------------------- /docs/rules/MoreThanOneLogger.md: -------------------------------------------------------------------------------- 1 | # MoreThanOneLogger 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:MoreThanOneLogger`
4 | > :warning: This rule is **deprecated** in favour of [S1312](https://rules.sonarsource.com/java/RSPEC-1312). 5 | 6 | ----- 7 | 8 | Normally only one logger is used in each class. 9 | -------------------------------------------------------------------------------- /docs/rules/NPathComplexity.md: -------------------------------------------------------------------------------- 1 | # NPathComplexity 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:NPathComplexity`
4 | 5 | 6 | ----- 7 | 8 | The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity. Example : 9 |
10 | public class Foo {
11 |   void bar() {
12 |    // lots of complicated code
13 |   }
14 |  }
15 | 
16 | -------------------------------------------------------------------------------- /docs/rules/NcssConstructorCount.md: -------------------------------------------------------------------------------- 1 | # NcssConstructorCount 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:NcssConstructorCount`
4 | > :warning: This rule is **deprecated** in favour of [S138](https://rules.sonarsource.com/java/RSPEC-138). 5 | 6 | ----- 7 | 8 | This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given constructor. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one. 9 | -------------------------------------------------------------------------------- /docs/rules/NcssMethodCount.md: -------------------------------------------------------------------------------- 1 | # NcssMethodCount 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:NcssMethodCount`
4 | > :warning: This rule is **deprecated** in favour of [S138](https://rules.sonarsource.com/java/RSPEC-138). 5 | 6 | ----- 7 | 8 | This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given method. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one. 9 | -------------------------------------------------------------------------------- /docs/rules/NoPackage.md: -------------------------------------------------------------------------------- 1 | # NoPackage 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:NoPackage`
4 | > :warning: This rule is **deprecated** in favour of [S1220](https://rules.sonarsource.com/java/RSPEC-1220). 5 | 6 | ----- 7 | 8 | Detects when a class or interface does not have a package definition. Example : 9 |
10 | // no package declaration
11 | public class ClassInDefaultPackage {
12 | }
13 |   
14 | -------------------------------------------------------------------------------- /docs/rules/NonCaseLabelInSwitchStatement.md: -------------------------------------------------------------------------------- 1 | # NonCaseLabelInSwitchStatement 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:NonCaseLabelInSwitchStatement`
4 | > :warning: This rule is **deprecated** in favour of [S1219](https://rules.sonarsource.com/java/RSPEC-1219). 5 | 6 | ----- 7 | 8 | A non-case label (e.g. a named break/continue label) was present in a switch statement. This legal, but confusing. It is easy to mix up the case labels and the non-case labels. 9 | -------------------------------------------------------------------------------- /docs/rules/NullAssignment.md: -------------------------------------------------------------------------------- 1 | # NullAssignment 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:NullAssignment`
4 | 5 | 6 | ----- 7 | 8 | Assigning a null to a variable (outside of its declaration) is usually bad form. Some times, the assignment is an indication that the programmer doesn't completely understand what is going on in the code. NOTE: This sort of assignment may in rare cases be useful to encourage garbage collection. If that's what you're using it for, by all means, disregard this rule :-) 9 | -------------------------------------------------------------------------------- /docs/rules/OnlyOneReturn.md: -------------------------------------------------------------------------------- 1 | # OnlyOneReturn 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:OnlyOneReturn`
4 | > :warning: This rule is **deprecated** in favour of [S1142](https://rules.sonarsource.com/java/RSPEC-1142). 5 | 6 | ----- 7 | 8 | A method should have only one exit point, and that should be the last statement in the method. 9 | -------------------------------------------------------------------------------- /docs/rules/PackageCase.md: -------------------------------------------------------------------------------- 1 | # PackageCase 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:PackageCase`
4 | > :warning: This rule is **deprecated** in favour of [S120](https://rules.sonarsource.com/java/RSPEC-120). 5 | 6 | ----- 7 | 8 | Detects when a package definition contains upper case characters. Example : 9 |
10 | package com.MyCompany;  // <- should be lower case name
11 | public class SomeClass {
12 | }
13 | 
14 | -------------------------------------------------------------------------------- /docs/rules/PositionLiteralsFirstInComparisons.md: -------------------------------------------------------------------------------- 1 | # PositionLiteralsFirstInComparisons 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:PositionLiteralsFirstInComparisons`
4 | > :warning: This rule is **deprecated** in favour of [S1132](https://rules.sonarsource.com/java/RSPEC-1132). 5 | 6 | ----- 7 | 8 | Position literals first in String comparisons - that way if the String is null you won't get a NullPointerException, it'll just return false. 9 | -------------------------------------------------------------------------------- /docs/rules/PreserveStackTrace.md: -------------------------------------------------------------------------------- 1 | # PreserveStackTrace 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:PreserveStackTrace`
4 | > :warning: This rule is **deprecated** in favour of [S1166](https://rules.sonarsource.com/java/RSPEC-1166). 5 | 6 | ----- 7 | 8 | Throwing a new exception from a catch block without passing the original exception into the new Exception will cause the true stack trace to be lost, and can make it difficult to debug effectively. 9 | -------------------------------------------------------------------------------- /docs/rules/ProperCloneImplementation.md: -------------------------------------------------------------------------------- 1 | # ProperCloneImplementation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ProperCloneImplementation`
4 | > :warning: This rule is **deprecated** in favour of [S1182](https://rules.sonarsource.com/java/RSPEC-1182). 5 | 6 | ----- 7 | 8 | Object clone() should be implemented with super.clone(). Example : 9 |
10 | class Foo{
11 |     public Object clone(){
12 |         return new Foo(); // This is bad
13 |     }
14 | }
15 |   
16 | -------------------------------------------------------------------------------- /docs/rules/ProperLogger.md: -------------------------------------------------------------------------------- 1 | # ProperLogger 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ProperLogger`
4 | > :warning: This rule is **deprecated** in favour of [S1312](https://rules.sonarsource.com/java/RSPEC-1312). 5 | 6 | ----- 7 | 8 | Logger should normally be defined private static final and have the correct class. Private final Log log; is also allowed for rare cases when loggers need to be passed around, but the logger needs to be passed into the constructor. 9 | -------------------------------------------------------------------------------- /docs/rules/RemoteInterfaceNamingConvention.md: -------------------------------------------------------------------------------- 1 | # RemoteInterfaceNamingConvention 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:RemoteInterfaceNamingConvention`
4 | 5 | 6 | ----- 7 | 8 | Remote Interface of a Session EJB should NOT be suffixed. 9 | -------------------------------------------------------------------------------- /docs/rules/RemoteSessionInterfaceNamingConvention.md: -------------------------------------------------------------------------------- 1 | # RemoteSessionInterfaceNamingConvention 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:RemoteSessionInterfaceNamingConvention`
4 | 5 | 6 | ----- 7 | 8 | Remote Home interface of a Session EJB should be suffixed by "Home". 9 | -------------------------------------------------------------------------------- /docs/rules/ReplaceEnumerationWithIterator.md: -------------------------------------------------------------------------------- 1 | # ReplaceEnumerationWithIterator 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ReplaceEnumerationWithIterator`
4 | > :warning: This rule is **deprecated** in favour of [S1150](https://rules.sonarsource.com/java/RSPEC-1150). 5 | 6 | ----- 7 | 8 | Consider replacing this Enumeration with the newer java.util.Iterator 9 | -------------------------------------------------------------------------------- /docs/rules/ReplaceHashtableWithMap.md: -------------------------------------------------------------------------------- 1 | # ReplaceHashtableWithMap 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ReplaceHashtableWithMap`
4 | > :warning: This rule is **deprecated** in favour of [S1149](https://rules.sonarsource.com/java/RSPEC-1149). 5 | 6 | ----- 7 | 8 | Consider replacing this Hashtable with the newer java.util.Map 9 | -------------------------------------------------------------------------------- /docs/rules/ReplaceVectorWithList.md: -------------------------------------------------------------------------------- 1 | # ReplaceVectorWithList 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ReplaceVectorWithList`
4 | > :warning: This rule is **deprecated** in favour of [S1149](https://rules.sonarsource.com/java/RSPEC-1149). 5 | 6 | ----- 7 | 8 | Consider replacing Vector usages with the newer java.util.ArrayList if expensive threadsafe operation is not required. 9 | -------------------------------------------------------------------------------- /docs/rules/ReturnFromFinallyBlock.md: -------------------------------------------------------------------------------- 1 | # ReturnFromFinallyBlock 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ReturnFromFinallyBlock`
4 | > :warning: This rule is **deprecated** in favour of [S1143](https://rules.sonarsource.com/java/RSPEC-1143). 5 | 6 | ----- 7 | 8 | Avoid returning from a finally block - this can discard exceptions. 9 | -------------------------------------------------------------------------------- /docs/rules/ShortClassName.md: -------------------------------------------------------------------------------- 1 | # ShortClassName 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ShortClassName`
4 | > :warning: This rule is **deprecated** in favour of [S101](https://rules.sonarsource.com/java/RSPEC-101). 5 | 6 | ----- 7 | 8 | Classnames with fewer than five characters are not recommended. Example: 9 |
10 | public class Foo {
11 | }
12 | 
13 | -------------------------------------------------------------------------------- /docs/rules/ShortInstantiation.md: -------------------------------------------------------------------------------- 1 | # ShortInstantiation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ShortInstantiation`
4 | 5 | 6 | ----- 7 | 8 | In JDK 1.5, calling new Short() causes memory allocation. Short.valueOf() is more memory friendly. Example : 9 |
10 | public class Foo {
11 | private Short i = new Short(0); // change to Short i =
12 | Short.valueOf(0);
13 | }
14 |   
15 | -------------------------------------------------------------------------------- /docs/rules/ShortMethodName.md: -------------------------------------------------------------------------------- 1 | # ShortMethodName 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ShortMethodName`
4 | > :warning: This rule is **deprecated** in favour of [S100](https://rules.sonarsource.com/java/RSPEC-100). 5 | 6 | ----- 7 | 8 | Detects when very short method names are used. Example : 9 |
10 | public class ShortMethod {
11 |   public void a( int i ) { // Violation
12 |   }
13 | }
14 | 
15 | -------------------------------------------------------------------------------- /docs/rules/ShortVariable.md: -------------------------------------------------------------------------------- 1 | # ShortVariable 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:ShortVariable`
4 | > :warning: This rule is **deprecated** in favour of [S117](https://rules.sonarsource.com/java/RSPEC-117). 5 | 6 | ----- 7 | 8 | Detects when a field, local, or parameter has a very short name. 9 | -------------------------------------------------------------------------------- /docs/rules/SignatureDeclareThrowsException.md: -------------------------------------------------------------------------------- 1 | # SignatureDeclareThrowsException 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:SignatureDeclareThrowsException`
4 | > :warning: This rule is **deprecated** in favour of [S112](https://rules.sonarsource.com/java/RSPEC-112). 5 | 6 | ----- 7 | 8 | It is unclear which exceptions that can be thrown from the methods. It might be difficult to document and understand the vague interfaces. Use either a class derived from RuntimeException or a checked exception. 9 | -------------------------------------------------------------------------------- /docs/rules/SimpleDateFormatNeedsLocale.md: -------------------------------------------------------------------------------- 1 | # SimpleDateFormatNeedsLocale 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:SimpleDateFormatNeedsLocale`
4 | 5 | 6 | ----- 7 | 8 | Be sure to specify a Locale when creating a new instance of SimpleDateFormat. 9 | -------------------------------------------------------------------------------- /docs/rules/SimplifyBooleanExpressions.md: -------------------------------------------------------------------------------- 1 | # SimplifyBooleanExpressions 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:SimplifyBooleanExpressions`
4 | > :warning: This rule is **deprecated** in favour of [S1125](https://rules.sonarsource.com/java/RSPEC-1125). 5 | 6 | ----- 7 | 8 | Avoid unnecessary comparisons in boolean expressions - this complicates simple code. Example : 9 |
10 | public class Bar {
11 |  // can be simplified to
12 |  // bar = isFoo();
13 |  private boolean bar = (isFoo() == true);
14 | 
15 |  public isFoo() { return false;}
16 | }
17 | 
18 | -------------------------------------------------------------------------------- /docs/rules/SimplifyConditional.md: -------------------------------------------------------------------------------- 1 | # SimplifyConditional 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:SimplifyConditional`
4 | 5 | 6 | ----- 7 | 8 | No need to check for null before an instanceof; the instanceof keyword returns false when given a null argument. 9 | -------------------------------------------------------------------------------- /docs/rules/SimplifyStartsWith.md: -------------------------------------------------------------------------------- 1 | # SimplifyStartsWith 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:SimplifyStartsWith`
4 | 5 | 6 | ----- 7 | 8 | Since it passes in a literal of length 1, this call to String.startsWith can be rewritten using String.charAt(0) to save some time. 9 | -------------------------------------------------------------------------------- /docs/rules/SingularField.md: -------------------------------------------------------------------------------- 1 | # SingularField 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:SingularField`
4 | 5 | 6 | ----- 7 | 8 | A field that's only used by one method could perhaps be replaced by a local variable. 9 | -------------------------------------------------------------------------------- /docs/rules/StaticEJBFieldShouldBeFinal.md: -------------------------------------------------------------------------------- 1 | # StaticEJBFieldShouldBeFinal 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:StaticEJBFieldShouldBeFinal`
4 | 5 | 6 | ----- 7 | 8 | According to the J2EE specification (p.494), an EJB should not have any static fields with write access. However, static read only fields are allowed. This ensures proper behavior especially when instances are distributed by the container on several JREs. 9 | -------------------------------------------------------------------------------- /docs/rules/StringBufferInstantiationWithChar.md: -------------------------------------------------------------------------------- 1 | # StringBufferInstantiationWithChar 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:StringBufferInstantiationWithChar`
4 | > :warning: This rule is **deprecated** in favour of [S1317](https://rules.sonarsource.com/java/RSPEC-1317). 5 | 6 | ----- 7 | 8 | StringBuffer sb = new StringBuffer('c'); The char will be converted into int to intialize StringBuffer size. 9 | -------------------------------------------------------------------------------- /docs/rules/StringInstantiation.md: -------------------------------------------------------------------------------- 1 | # StringInstantiation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:StringInstantiation`
4 | 5 | 6 | ----- 7 | 8 | Avoid instantiating String objects; this is usually unnecessary. 9 | -------------------------------------------------------------------------------- /docs/rules/StringToString.md: -------------------------------------------------------------------------------- 1 | # StringToString 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:StringToString`
4 | > :warning: This rule is **deprecated** in favour of [S1858](https://rules.sonarsource.com/java/RSPEC-1858). 5 | 6 | ----- 7 | 8 | Avoid calling toString() on String objects; this is unnecessary. 9 | -------------------------------------------------------------------------------- /docs/rules/SwitchDensity.md: -------------------------------------------------------------------------------- 1 | # SwitchDensity 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:SwitchDensity`
4 | > :warning: This rule is **deprecated** in favour of [S1151](https://rules.sonarsource.com/java/RSPEC-1151). 5 | 6 | ----- 7 | 8 | A high ratio of statements to labels in a switch statement implies that the switch statement is doing too much work. Consider moving the statements into new methods, or creating subclasses based on the switch variable. 9 | -------------------------------------------------------------------------------- /docs/rules/SwitchStmtsShouldHaveDefault.md: -------------------------------------------------------------------------------- 1 | # SwitchStmtsShouldHaveDefault 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:SwitchStmtsShouldHaveDefault`
4 | > :warning: This rule is **deprecated** in favour of `java:SwitchLastCaseIsDefaultCheck`. 5 | 6 | ----- 7 | 8 | Switch statements should have a default label. Example : 9 |
10 | public class Foo {
11 |  public void bar() {
12 |   int x = 2;
13 |   switch (x) {
14 |    case 2: int j = 8;
15 |   }
16 |  }
17 | }
18 | 
19 | -------------------------------------------------------------------------------- /docs/rules/SystemPrintln.md: -------------------------------------------------------------------------------- 1 | # SystemPrintln 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:SystemPrintln`
4 | > :warning: This rule is **deprecated** in favour of [S106](https://rules.sonarsource.com/java/RSPEC-106). 5 | 6 | ----- 7 | 8 | System.(out|err).print is used, consider using a logger. 9 | -------------------------------------------------------------------------------- /docs/rules/TooManyFields.md: -------------------------------------------------------------------------------- 1 | # TooManyFields 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:TooManyFields`
4 | 5 | 6 | ----- 7 | 8 | Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field. 9 | -------------------------------------------------------------------------------- /docs/rules/TooManyMethods.md: -------------------------------------------------------------------------------- 1 | # TooManyMethods 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:TooManyMethods`
4 | > :warning: This rule is **deprecated** in favour of [S1448](https://rules.sonarsource.com/java/RSPEC-1448). 5 | 6 | ----- 7 | 8 | A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects. 9 | -------------------------------------------------------------------------------- /docs/rules/TooManyStaticImports.md: -------------------------------------------------------------------------------- 1 | # TooManyStaticImports 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:TooManyStaticImports`
4 | 5 | 6 | ----- 7 | 8 | If you overuse the static import feature, it can make your program unreadable and unmaintainable, polluting its namespace with all the static members you import. Readers of your code (including you, a few months after you wrote it) will not know which class a static member comes from (Sun 1.5 Language Guide). 9 | -------------------------------------------------------------------------------- /docs/rules/UncommentedEmptyConstructor.md: -------------------------------------------------------------------------------- 1 | # UncommentedEmptyConstructor 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UncommentedEmptyConstructor`
4 | > :warning: This rule is **deprecated** in favour of [S2094](https://rules.sonarsource.com/java/RSPEC-2094). 5 | 6 | ----- 7 | 8 | Uncommented Empty Constructor finds instances where a constructor does not contain statements, but there is no comment. By explicitly commenting empty constructors it is easier to distinguish between intentional (commented) and unintentional empty constructors. 9 | -------------------------------------------------------------------------------- /docs/rules/UncommentedEmptyMethodBody.md: -------------------------------------------------------------------------------- 1 | # UncommentedEmptyMethodBody 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UncommentedEmptyMethodBody`
4 | > :warning: This rule is **deprecated** in favour of [S1186](https://rules.sonarsource.com/java/RSPEC-1186). 5 | 6 | ----- 7 | 8 |

Uncommented Empty Method finds instances where a method does not contain statements, but there is no comment. By 9 | explicitly commenting empty methods it is easier to distinguish between intentional (commented) and unintentional 10 | empty methods.

11 | -------------------------------------------------------------------------------- /docs/rules/UnconditionalIfStatement.md: -------------------------------------------------------------------------------- 1 | # UnconditionalIfStatement 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnconditionalIfStatement`
4 | > :warning: This rule is **deprecated** in favour of [S2583](https://rules.sonarsource.com/java/RSPEC-2583). 5 | 6 | ----- 7 | 8 | Do not use if statements that are always true or always false. 9 | -------------------------------------------------------------------------------- /docs/rules/UnnecessaryCaseChange.md: -------------------------------------------------------------------------------- 1 | # UnnecessaryCaseChange 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnnecessaryCaseChange`
4 | > :warning: This rule is **deprecated** in favour of [S1157](https://rules.sonarsource.com/java/RSPEC-1157). 5 | 6 | ----- 7 | 8 | Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals() 9 | -------------------------------------------------------------------------------- /docs/rules/UnnecessaryConstructor.md: -------------------------------------------------------------------------------- 1 | # UnnecessaryConstructor 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnnecessaryConstructor`
4 | > :warning: This rule is **deprecated** in favour of [S1186](https://rules.sonarsource.com/java/RSPEC-1186). 5 | 6 | ----- 7 | 8 | This rule detects when a constructor is not necessary; i.e., when there's only one constructor, it's public, has an empty body, and takes no arguments. 9 | -------------------------------------------------------------------------------- /docs/rules/UnnecessaryConversionTemporary.md: -------------------------------------------------------------------------------- 1 | # UnnecessaryConversionTemporary 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnnecessaryConversionTemporary`
4 | > :warning: This rule is **deprecated** in favour of [S1158](https://rules.sonarsource.com/java/RSPEC-1158). 5 | 6 | ----- 7 | 8 | Avoid unnecessary temporaries when converting primitives to Strings 9 | -------------------------------------------------------------------------------- /docs/rules/UnnecessaryFinalModifier.md: -------------------------------------------------------------------------------- 1 | # UnnecessaryFinalModifier 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnnecessaryFinalModifier`
4 | 5 | 6 | ----- 7 | 8 | When a class has the final modifier, all the methods are automatically final. 9 | -------------------------------------------------------------------------------- /docs/rules/UnnecessaryLocalBeforeReturn.md: -------------------------------------------------------------------------------- 1 | # UnnecessaryLocalBeforeReturn 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnnecessaryLocalBeforeReturn`
4 | > :warning: This rule is **deprecated** in favour of [S1488](https://rules.sonarsource.com/java/RSPEC-1488). 5 | 6 | ----- 7 | 8 | Avoid unnecessarily creating local variables 9 | -------------------------------------------------------------------------------- /docs/rules/UnnecessaryParentheses.md: -------------------------------------------------------------------------------- 1 | # UnnecessaryParentheses 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnnecessaryParentheses`
4 | > :warning: This rule is **deprecated** in favour of `java:UselessParenthesesCheck`. 5 | 6 | ----- 7 | 8 | Sometimes expressions are wrapped in unnecessary parentheses, making them look like a function call. Example : 9 |
10 | public class Foo {
11 |   boolean bar() {
12 |     return (true);
13 |   }
14 | }
15 | 
16 | -------------------------------------------------------------------------------- /docs/rules/UnnecessaryReturn.md: -------------------------------------------------------------------------------- 1 | # UnnecessaryReturn 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnnecessaryReturn`
4 | 5 | 6 | ----- 7 | 8 | Avoid unnecessary return statements 9 | -------------------------------------------------------------------------------- /docs/rules/UnnecessaryWrapperObjectCreation.md: -------------------------------------------------------------------------------- 1 | # UnnecessaryWrapperObjectCreation 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnnecessaryWrapperObjectCreation`
4 | > :warning: This rule is **deprecated** in favour of [S1158](https://rules.sonarsource.com/java/RSPEC-1158). 5 | 6 | ----- 7 | 8 | Parsing method should be called directy instead. 9 | -------------------------------------------------------------------------------- /docs/rules/UnsynchronizedStaticDateFormatter.md: -------------------------------------------------------------------------------- 1 | # UnsynchronizedStaticDateFormatter 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnsynchronizedStaticDateFormatter`
4 | > :warning: This rule is **deprecated** in favour of [S2156](https://rules.sonarsource.com/java/RSPEC-2156). 5 | 6 | ----- 7 | 8 | SimpleDateFormat is not synchronized. Sun recomends separate format instances for each thread. If multiple threads must access a static formatter, the formatter must be synchronized either on method or block level. 9 | -------------------------------------------------------------------------------- /docs/rules/UnusedFormalParameter.md: -------------------------------------------------------------------------------- 1 | # UnusedFormalParameter 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnusedFormalParameter`
4 | > :warning: This rule is **deprecated** in favour of [S1172](https://rules.sonarsource.com/java/RSPEC-1172). 5 | 6 | ----- 7 | 8 |

Avoid passing parameters to methods or constructors and then not using those parameters.

9 | -------------------------------------------------------------------------------- /docs/rules/UnusedImports.md: -------------------------------------------------------------------------------- 1 | # UnusedImports 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnusedImports`
4 | > :warning: This rule is **deprecated** in favour of `java:UselessImportCheck`. 5 | 6 | ----- 7 | 8 | Avoid unused import statements. Example : 9 |
10 | // this is bad
11 | import java.io.File;
12 | public class Foo {}
13 |   
14 | -------------------------------------------------------------------------------- /docs/rules/UnusedImportsWithTypeResolution.md: -------------------------------------------------------------------------------- 1 | # UnusedImportsWithTypeResolution 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnusedImportsWithTypeResolution`
4 | > :warning: This rule is **deprecated** in favour of `java:UselessImportCheck`. 5 | 6 | ----- 7 | 8 | Avoid unused import statements. This rule will find unused on demand imports, i.e. import com.foo.*. Example: 9 |
10 | import java.io.*; // not referenced or required
11 | 
12 | public class Foo {}
13 | 
14 | -------------------------------------------------------------------------------- /docs/rules/UnusedLocalVariable.md: -------------------------------------------------------------------------------- 1 | # UnusedLocalVariable 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnusedLocalVariable`
4 | > :warning: This rule is **deprecated** in favour of [S1481](https://rules.sonarsource.com/java/RSPEC-1481). 5 | 6 | ----- 7 | 8 | Detects when a local variable is declared and/or assigned, but not used. 9 | -------------------------------------------------------------------------------- /docs/rules/UnusedModifier.md: -------------------------------------------------------------------------------- 1 | # UnusedModifier 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnusedModifier`
4 | 5 | 6 | ----- 7 | 8 | Fields in interfaces are automatically public static final, and methods are public abstract. Classes or interfaces nested in an interface are automatically public and static (all nested interfaces are automatically static). For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous. 9 | -------------------------------------------------------------------------------- /docs/rules/UnusedNullCheckInEquals.md: -------------------------------------------------------------------------------- 1 | # UnusedNullCheckInEquals 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnusedNullCheckInEquals`
4 | 5 | 6 | ----- 7 | 8 | After checking an object reference for null, you should invoke equals() on that object rather than passing it to another object's equals() method. 9 | -------------------------------------------------------------------------------- /docs/rules/UnusedPrivateField.md: -------------------------------------------------------------------------------- 1 | # UnusedPrivateField 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnusedPrivateField`
4 | > :warning: This rule is **deprecated** in favour of [S1068](https://rules.sonarsource.com/java/RSPEC-1068). 5 | 6 | ----- 7 | 8 | Detects when a private field is declared and/or assigned a value, but not used. 9 | -------------------------------------------------------------------------------- /docs/rules/UnusedPrivateMethod.md: -------------------------------------------------------------------------------- 1 | # UnusedPrivateMethod 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UnusedPrivateMethod`
4 | > :warning: This rule is **deprecated** in favour of `java:UnusedPrivateMethod`. 5 | 6 | ----- 7 | 8 |

9 | Unused Private Method detects when a private method is declared but is unused. This PMD rule should be switched off 10 | and replaced by its equivalent from Squid that is more effective : it generates less false-positives and detects more 11 | dead code. 12 |

13 | -------------------------------------------------------------------------------- /docs/rules/UseArrayListInsteadOfVector.md: -------------------------------------------------------------------------------- 1 | # UseArrayListInsteadOfVector 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseArrayListInsteadOfVector`
4 | > :warning: This rule is **deprecated** in favour of [S1149](https://rules.sonarsource.com/java/RSPEC-1149). 5 | 6 | ----- 7 | 8 | ArrayList is a much better Collection implementation than Vector. 9 | -------------------------------------------------------------------------------- /docs/rules/UseArraysAsList.md: -------------------------------------------------------------------------------- 1 | # UseArraysAsList 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseArraysAsList`
4 | 5 | 6 | ----- 7 | 8 | The class java.util.Arrays has a asList method that should be use when you want to create a new List from an array of objects. It is faster than executing a loop to cpy all the elements of the array one by one 9 | -------------------------------------------------------------------------------- /docs/rules/UseCollectionIsEmpty.md: -------------------------------------------------------------------------------- 1 | # UseCollectionIsEmpty 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseCollectionIsEmpty`
4 | > :warning: This rule is **deprecated** in favour of [S1155](https://rules.sonarsource.com/java/RSPEC-1155). 5 | 6 | ----- 7 | 8 | The isEmpty() method on java.util.Collection is provided to see if a collection has any elements. Comparing the value of size() to 0 merely duplicates existing behavior. 9 | -------------------------------------------------------------------------------- /docs/rules/UseConcurrentHashMap.md: -------------------------------------------------------------------------------- 1 | # UseConcurrentHashMap 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseConcurrentHashMap`
4 | 5 | 6 | ----- 7 | 8 | Since Java5 brought a new implementation of the Map interface, specially designed for concurrent application. 9 | -------------------------------------------------------------------------------- /docs/rules/UseCorrectExceptionLogging.md: -------------------------------------------------------------------------------- 1 | # UseCorrectExceptionLogging 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseCorrectExceptionLogging`
4 | > :warning: This rule is **deprecated** in favour of [S1166](https://rules.sonarsource.com/java/RSPEC-1166). 5 | 6 | ----- 7 | 8 | To make sure the full stacktrace is printed out, use the logging statement with 2 arguments: a String and a Throwable. 9 | -------------------------------------------------------------------------------- /docs/rules/UseEqualsToCompareStrings.md: -------------------------------------------------------------------------------- 1 | # UseEqualsToCompareStrings 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseEqualsToCompareStrings`
4 | > :warning: This rule is **deprecated** in favour of `java:StringEqualityComparisonCheck`, [S1698](https://rules.sonarsource.com/java/RSPEC-1698). 5 | 6 | ----- 7 | 8 | Using "==" or "!=" to compare strings only works if intern version is used on both sides. 9 | -------------------------------------------------------------------------------- /docs/rules/UseIndexOfChar.md: -------------------------------------------------------------------------------- 1 | # UseIndexOfChar 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseIndexOfChar`
4 | 5 | 6 | ----- 7 | 8 | Use String.indexOf(char) when checking for the index of a single character; it executes faster. 9 | -------------------------------------------------------------------------------- /docs/rules/UseLocaleWithCaseConversions.md: -------------------------------------------------------------------------------- 1 | # UseLocaleWithCaseConversions 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseLocaleWithCaseConversions`
4 | 5 | 6 | ----- 7 | 8 | When doing a String.toLowerCase()/toUpperCase() call, use a Locale. This avoids problems with certain locales, i.e. Turkish. 9 | -------------------------------------------------------------------------------- /docs/rules/UseNotifyAllInsteadOfNotify.md: -------------------------------------------------------------------------------- 1 | # UseNotifyAllInsteadOfNotify 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseNotifyAllInsteadOfNotify`
4 | > :warning: This rule is **deprecated** in favour of [S2446](https://rules.sonarsource.com/java/RSPEC-2446). 5 | 6 | ----- 7 | 8 | Thread.notify() awakens a thread monitoring the object. If more than one thread is monitoring, then only one is chosen. The thread chosen is arbitrary; thus it's usually safer to call notifyAll() instead. 9 | -------------------------------------------------------------------------------- /docs/rules/UseProperClassLoader.md: -------------------------------------------------------------------------------- 1 | # UseProperClassLoader 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseProperClassLoader`
4 | 5 | 6 | ----- 7 | 8 | In J2EE getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead. 9 | -------------------------------------------------------------------------------- /docs/rules/UseStringBufferForStringAppends.md: -------------------------------------------------------------------------------- 1 | # UseStringBufferForStringAppends 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseStringBufferForStringAppends`
4 | 5 | 6 | ----- 7 | 8 | Finds usages of += for appending strings. 9 | -------------------------------------------------------------------------------- /docs/rules/UseStringBufferLength.md: -------------------------------------------------------------------------------- 1 | # UseStringBufferLength 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UseStringBufferLength`
4 | 5 | 6 | ----- 7 | 8 | Use StringBuffer.length() to determine StringBuffer length rather than using StringBuffer.toString().equals() or StringBuffer.toString().length() ==. 9 | -------------------------------------------------------------------------------- /docs/rules/UselessOperationOnImmutable.md: -------------------------------------------------------------------------------- 1 | # UselessOperationOnImmutable 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UselessOperationOnImmutable`
4 | 5 | 6 | ----- 7 | 8 | An operation on an Immutable object (BigDecimal or BigInteger) won't change the object itself. The result of the operation is a new object. Therefore, ignoring the operation result is an error. 9 | -------------------------------------------------------------------------------- /docs/rules/UselessOverridingMethod.md: -------------------------------------------------------------------------------- 1 | # UselessOverridingMethod 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UselessOverridingMethod`
4 | > :warning: This rule is **deprecated** in favour of [S1185](https://rules.sonarsource.com/java/RSPEC-1185). 5 | 6 | ----- 7 | 8 | The overriding method merely calls the same method defined in a superclass 9 | -------------------------------------------------------------------------------- /docs/rules/UselessParentheses.md: -------------------------------------------------------------------------------- 1 | # UselessParentheses 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UselessParentheses`
4 | > :warning: This rule is **deprecated** in favour of `java:UselessParenthesesCheck`. 5 | 6 | ----- 7 | 8 | Useless parentheses should be removed. Example: 9 |
10 | public class Foo {
11 | 
12 |    private int _bar1;
13 |    private Integer _bar2;
14 | 
15 |    public void setBar(int n) {
16 |       _bar1 = Integer.valueOf((n)); // here
17 |       _bar2 = (n); // and here
18 |    }
19 | 
20 | }
21 | 
22 | -------------------------------------------------------------------------------- /docs/rules/UselessStringValueOf.md: -------------------------------------------------------------------------------- 1 | # UselessStringValueOf 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:UselessStringValueOf`
4 | > :warning: This rule is **deprecated** in favour of [S1153](https://rules.sonarsource.com/java/RSPEC-1153). 5 | 6 | ----- 7 | 8 | No need to call String.valueOf to append to a string; just use the valueOf() argument directly. 9 | -------------------------------------------------------------------------------- /docs/rules/VariableNamingConventions.md: -------------------------------------------------------------------------------- 1 | # VariableNamingConventions 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:VariableNamingConventions`
4 | > :warning: This rule is **deprecated** in favour of [S115](https://rules.sonarsource.com/java/RSPEC-115), [S116](https://rules.sonarsource.com/java/RSPEC-116). 5 | 6 | ----- 7 | 8 | A variable naming conventions rule - customize this to your liking. Currently, it checks for final variables that should be fully capitalized and non-final variables that should not include underscores. 9 | -------------------------------------------------------------------------------- /docs/rules/WhileLoopsMustUseBraces.md: -------------------------------------------------------------------------------- 1 | # WhileLoopsMustUseBraces 2 | **Category:** `pmd`
3 | **Rule Key:** `pmd:WhileLoopsMustUseBraces`
4 | > :warning: This rule is **deprecated** in favour of [S121](https://rules.sonarsource.com/java/RSPEC-121). 5 | 6 | ----- 7 | 8 |

9 | Avoid using 'while' statements without using curly braces. 10 |

11 | -------------------------------------------------------------------------------- /integration-test/projects/pmd-avoid-duplicate-literals/src/main/java/AvoidDuplicateLiterals.java: -------------------------------------------------------------------------------- 1 | public class AvoidDuplicateLiterals { 2 | private String string1 = "\1\1\37\uffff\1\1"; 3 | private String string2 = "\1\1\37\uffff\1\1"; 4 | private String string3 = "\1\1\37\uffff\1\1"; 5 | private String string4 = "\1\1\37\uffff\1\1"; 6 | private String string5 = "\1\1\37\uffff\1\1"; 7 | } 8 | -------------------------------------------------------------------------------- /integration-test/projects/pmd-extensions/src/main/java/pmd/Bar.java: -------------------------------------------------------------------------------- 1 | package pmd; 2 | 3 | public class Bar extends Foo { 4 | public void method() { 5 | // PMD7-MIGRATION: added to force one violation in pmdShouldHaveAccessToExternalLibrariesInItsClasspath: is this testing the correct thing? 6 | if (true) System.out.println("violation on AvoidIfWithoutBrace"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration-test/projects/pmd-extensions/src/main/java/pmd/Foo.java: -------------------------------------------------------------------------------- 1 | package pmd; 2 | 3 | import java.io.IOException; 4 | 5 | public class Foo extends IOException { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /integration-test/projects/pmd-junit-rules/src/main/java/ProductionCode.java: -------------------------------------------------------------------------------- 1 | public class ProductionCode { 2 | private int unused; 3 | } 4 | -------------------------------------------------------------------------------- /integration-test/projects/pmd-junit-rules/src/test/java/ProductionCodeTest.java: -------------------------------------------------------------------------------- 1 | public class ProductionCodeTest extends junit.framework.TestCase { 2 | private int unused; 3 | } 4 | -------------------------------------------------------------------------------- /integration-test/src/test/resources/TestUtils.txt: -------------------------------------------------------------------------------- 1 | Required to locate test home directory -------------------------------------------------------------------------------- /integration-test/src/test/resources/com/sonar/it/java/PmdTest/pmd-backup.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | pmd 4 | java 5 | 6 | 7 | pmd 8 | AvoidDuplicateLiterals 9 | MINOR 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd-kotlin.properties: -------------------------------------------------------------------------------- 1 | rule.pmd-kotlin.FunctionNameTooShort.name=Function name too short 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-kotlin/FunctionNameTooShort.html: -------------------------------------------------------------------------------- 1 | 2 | Function names should be easy to understand and describe the intention. Makes developers happy. 3 |

Example:

4 |
 5 |   fun b() = 1
 6 | 
7 | 8 |

9 | This is a simple rule to test Kotlin in PMD. 10 |

11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/JUnit4SuitesShouldUseSuiteAnnotation.html: -------------------------------------------------------------------------------- 1 | In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicated 2 | through the @RunWith(Suite.class) annotation. Example: 3 |
 4 | public class BadExample extends TestCase{
 5 | 
 6 |     public static Test suite(){
 7 |     	return new Suite();
 8 |     }
 9 | }
10 | 
11 | @RunWith(Suite.class)
12 | @SuiteClasses( { TestOne.class, TestTwo.class })
13 | public class GoodTest {
14 | }
15 | 
16 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/JUnit4TestShouldUseAfterAnnotation.html: -------------------------------------------------------------------------------- 1 | In JUnit 3, the tearDown method was used to clean up all data entities required in running tests. 2 | JUnit 4 skips the tearDown method and executes all methods annotated with @After after running each test Example: 3 |
 4 | public class MyTest {
 5 |     public void tearDown() {
 6 |         bad();
 7 |     }
 8 | }
 9 | public class MyTest2 {
10 |     @After public void tearDown() {
11 |         good();
12 |     }
13 | }
14 | 
15 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/JUnit4TestShouldUseBeforeAnnotation.html: -------------------------------------------------------------------------------- 1 | In JUnit 3, the setUp method was used to set up all data entities required in running tests. 2 | JUnit 4 skips the setUp method and executes all methods annotated with @Before before all tests Example: 3 |
 4 | public class MyTest {
 5 |     public void setUp() {
 6 |         bad();
 7 |     }
 8 | }
 9 | public class MyTest2 {
10 |     @Before public void setUp() {
11 |         good();
12 |     }
13 | }
14 | 
15 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/JUnit4TestShouldUseTestAnnotation.html: -------------------------------------------------------------------------------- 1 | In JUnit 3, the framework executed all methods which started with the word test as a unit test. 2 | In JUnit 4, only methods annotated with the @Test annotation are executed. Example: 3 |
 4 | public class MyTest {
 5 |     public void testBad() {
 6 |         doSomething();
 7 |     }
 8 | 
 9 | 	@Test
10 |     public void testGood() {
11 |         doSomething();
12 |     }
13 | }
14 | 
15 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/JUnitAssertionsShouldIncludeMessage.html: -------------------------------------------------------------------------------- 1 | JUnit assertions should include a message - i.e., use the three argument version of assertEquals(), not the two argument version. 2 |
 3 | public class Foo extends TestCase {
 4 |   public void testSomething() {
 5 |     assertEquals("foo", "bar"); // violation, should be assertEquals("Foo does not equals bar", "foo", "bar");
 6 |   }
 7 | }
 8 | 
9 | 10 |

11 | This rule is deprecated, use {rule:java:S2698} instead. 12 |

13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/JUnitSpelling.html: -------------------------------------------------------------------------------- 1 | Some JUnit framework methods are easy to misspell. 2 |
 3 | import junit.framework.*;
 4 | 
 5 | public class Foo extends TestCase {
 6 |   public void setup() {} // violation, should be setUp()
 7 |   public void TearDown() {} // violation, should be tearDown()
 8 | }
 9 | 
10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/JUnitStaticSuite.html: -------------------------------------------------------------------------------- 1 | The suite() method in a JUnit test needs to be both public and static. 2 |
 3 | import junit.framework.*;
 4 | 
 5 | public class Foo extends TestCase {
 6 |   public void suite() {} // violation, should be static
 7 |   private static void suite() {} // violation, should be public
 8 | }
 9 | 
10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/JUnitTestsShouldIncludeAssert.html: -------------------------------------------------------------------------------- 1 | JUnit tests should include at least one assertion. This makes the tests more robust, and using assert with messages provide the developer a clearer idea of what the test does. 2 |
 3 | public class Foo extends TestCase {
 4 |   public void testSomething() {
 5 |     Bar b = findBar();
 6 |     b.work();
 7 |     // violation, we could use assertNotNull("bar not found", b);
 8 |   }
 9 | }
10 | 
11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/JUnitUseExpected.html: -------------------------------------------------------------------------------- 1 | In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions. Example: 2 |
 3 | public class MyTest {
 4 | 	@Test
 5 |     public void testBad() {
 6 |         try {
 7 |             doSomething();
 8 |             fail("should have thrown an exception");
 9 |         } catch (Exception e) {
10 |         }
11 |     }
12 | 
13 | 	@Test(expected=Exception.class)
14 |     public void testGood() {
15 |         doSomething();
16 |     }
17 | }
18 | 
19 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/SimplifyBooleanAssertion.html: -------------------------------------------------------------------------------- 1 | Avoid negation in an assertTrue or assertFalse test. For example, rephrase: assertTrue(!expr); as: assertFalse(expr); 2 |
 3 | public class SimpleTest extends TestCase {
 4 |   public void testX() {
 5 |     assertTrue("not empty", !r.isEmpty()); // violation, replace with assertFalse("not empty", r.isEmpty())
 6 |     assertFalse(!r.isEmpty()); // violation, replace with assertTrue("empty", r.isEmpty())
 7 |   }
 8 | }
 9 | 
10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/UnnecessaryBooleanAssertion.html: -------------------------------------------------------------------------------- 1 | A JUnit test assertion with a boolean literal is unnecessary since it always will eval to the same thing. Consider using flow control (in case of assertTrue(false) or similar) or simply removing statements like assertTrue(true) and assertFalse(false). If you just want a test to halt, use the fail method. 2 |
3 | public class SimpleTest extends TestCase {
4 |   public void testX() {
5 |     assertTrue(true); // violation
6 |   }
7 | }
8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/UseAssertEqualsInsteadOfAssertTrue.html: -------------------------------------------------------------------------------- 1 | This rule detects JUnit assertions in object equality. These assertions should be made by more specific methods, like assertEquals. 2 |
 3 | public class FooTest extends TestCase {
 4 |   void testCode() {
 5 |     Object a, b;
 6 | 
 7 |     assertTrue(a.equals(b)); // violation
 8 |     assertEquals("a should equals b", a, b); // good usage
 9 |   }
10 | }
11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/UseAssertSameInsteadOfAssertTrue.html: -------------------------------------------------------------------------------- 1 | This rule detects JUnit assertions in object references equality. These assertions should be made by more specific methods, like assertSame, assertNotSame. 2 |
 3 | public class FooTest extends TestCase {
 4 |   void testCode() {
 5 |     Object a, b;
 6 | 
 7 |     assertTrue(a==b); // violation
 8 |     assertSame(a, b); // good usage
 9 |   }
10 | }
11 | 
12 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd-unit-tests/UseAssertTrueInsteadOfAssertEquals.html: -------------------------------------------------------------------------------- 1 | When asserting a value is the same as a boolean literal, use assertTrue/assertFalse, instead of assertEquals. Example: 2 |
 3 | public class MyTestCase extends TestCase {
 4 | 	public void testMyCase() {
 5 | 		boolean myVar = true;
 6 | 		// Ok
 7 | 		assertTrue("myVar is true", myVar);
 8 | 		// Bad
 9 | 		assertEquals("myVar is true", true, myVar);
10 | 		// Bad
11 | 		assertEquals("myVar is false", false, myVar);
12 | 	}
13 | }
14 | 
15 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AbstractClassWithoutAbstractMethod.html: -------------------------------------------------------------------------------- 1 | 2 | The abstract class does not contain any abstract methods. An abstract class suggests an incomplete implementation, which is to be completed by subclasses implementing the abstract methods. If the class is intended to be used as a base class only (not to be instantiated directly) a protected constructor can be provided prevent direct instantiation. 3 | 4 |

5 | This rule is deprecated, use {rule:java:S1694} instead. 6 |

7 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AbstractNaming.html: -------------------------------------------------------------------------------- 1 | 2 | Abstract classes should be named 'AbstractXXX'. 3 |

Example:

h2> 4 |
 5 | public abstract class Foo { // should be AbstractFoo
 6 | }
 7 |   
8 | 9 |

10 | This rule is deprecated, use {rule:java:S118} instead. 11 |

12 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AddEmptyString.html: -------------------------------------------------------------------------------- 1 | 2 | The conversion of literals to strings by concatenating them with empty strings is inefficient. 3 | It is much better to use one of the type-specific toString() methods instead. 4 | 5 |

Example:

6 |
 7 | String s = "" + 123;                // inefficient
 8 | String t = Integer.toString(456);   // preferred approach
 9 | 
10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AppendCharacterWithChar.html: -------------------------------------------------------------------------------- 1 | 2 | Avoid concatenating characters as strings in StringBuffer/StringBuilder.append methods. 3 | 4 |

Noncompliant Code Example

5 |
 6 | StringBuffer sb = new StringBuffer();
 7 | sb.append("a");     // avoid this
 8 | 
9 |

Compliant Solution

10 |
11 | StringBuffer sb = new StringBuffer();
12 | sb.append('a');     // use this instead
13 | 
14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ArrayIsStoredDirectly.html: -------------------------------------------------------------------------------- 1 | 2 | Constructors and methods receiving arrays should clone objects and store the copy. This prevents future changes from the user from affecting the original array. 3 | 4 |

5 | This rule is deprecated, use {rule:java:S2384} instead. 6 |

7 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AssignmentInOperand.html: -------------------------------------------------------------------------------- 1 | 2 | Avoid assignments in operands; this can make code more complicated and harder to read. 3 | 4 |

Example:

5 |
 6 | public void bar() {
 7 |   int x = 2;
 8 |   if ((x = getX()) == 3) {
 9 |     System.out.println("3!");
10 |   }
11 | }
12 | 
13 | 14 |

15 | This rule is deprecated, use {rule:java:AssignmentInSubExpressionCheck} instead. 16 |

17 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AssignmentToNonFinalStatic.html: -------------------------------------------------------------------------------- 1 | 2 | Identifies a possible unsafe usage of a static field. 3 | 4 |

Example:

5 |
 6 | public class StaticField {
 7 |  static int x;
 8 |  public FinalFields(int y) {
 9 |   x = y; // unsafe
10 |  }
11 | }
12 | 
13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AtLeastOneConstructor.html: -------------------------------------------------------------------------------- 1 | Each non-static class should declare at least one constructor. Classes with solely static members ("Utility class") are ignored. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1118} or {rule:java:S1258} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidAssertAsIdentifier.html: -------------------------------------------------------------------------------- 1 | 2 | Use of the term assert will conflict with newer versions of Java since it is a reserved word. 3 | 4 |

5 | This rule is deprecated, use {rule:java:S1190} instead. 6 |

7 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidCallingFinalize.html: -------------------------------------------------------------------------------- 1 | 2 |

3 | The method Object.finalize() is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. 4 | It should not be invoked by application logic. 5 |

6 |

7 | Note that Oracle has declared Object.finalize() as deprecated since JDK 9. 8 |

9 | 10 |

11 | This rule is deprecated, use {rule:java:ObjectFinalizeCheck} instead. 12 |

13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidCatchingGenericException.html: -------------------------------------------------------------------------------- 1 | 2 | Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block. 3 | 4 |

5 | This rule is deprecated, use {rule:java:S2221} instead. 6 |

7 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidCatchingNPE.html: -------------------------------------------------------------------------------- 1 | 2 | Code should never throw NullPointerExceptions under normal circumstances. 3 | A catch block may hide the original error, causing other, more subtle problems later on. 4 | 5 |

6 | This rule is deprecated, use {rule:java:S1696} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidCatchingThrowable.html: -------------------------------------------------------------------------------- 1 | 2 | Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as 3 | OutOfMemoryError that should be exposed and managed separately. 4 | 5 |

6 | This rule is deprecated, use {rule:java:S1181} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidConstantsInterface.html: -------------------------------------------------------------------------------- 1 | 2 |

3 | Avoid constants in interfaces. Interfaces should define types, constants are implementation details better placed in 4 | classes or enums. 5 |

6 |

7 | See Effective Java, item 19. 8 |

9 |

10 | This rule is deprecated, use {rule:java:S1214} instead. 11 |

12 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidDeeplyNestedIfStmts.html: -------------------------------------------------------------------------------- 1 | 2 | Avoid creating deeply nested if-then statements since they are harder to read and error-prone to maintain. 3 | 4 |

5 | This rule is deprecated, use {rule:java:S134} instead. 6 |

7 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidDollarSigns.html: -------------------------------------------------------------------------------- 1 |

2 | Avoid using dollar signs in variable/method/class/interface names. 3 |

4 | 5 |

6 | This rule is deprecated, use {rule:java:S114}, {rule:java:S115}, {rule:java:S116} and {rule:java:S117} 7 | instead. 8 |

9 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidDuplicateLiterals.html: -------------------------------------------------------------------------------- 1 | Code containing duplicate String literals can usually be improved by declaring the String as a constant field. Example : 2 |
 3 | public class Foo {
 4 |  private void bar() {
 5 |     buz("Howdy");
 6 |     buz("Howdy");
 7 |     buz("Howdy");
 8 |     buz("Howdy");
 9 |  }
10 |  private void buz(String x) {}
11 | }
12 | 
13 | 14 |

15 | This rule is deprecated, use {rule:java:S1192} instead. 16 |

17 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidEnumAsIdentifier.html: -------------------------------------------------------------------------------- 1 | Finds all places 'enum' is used as an identifier is used. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1190} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidFieldNameMatchingMethodName.html: -------------------------------------------------------------------------------- 1 | It is somewhat confusing to have a field name with the same name as a method. While this is totally legal, having information (field) and actions (method) is not clear naming. Example : 2 |
 3 | public class Foo {
 4 |   Object bar;
 5 |   // bar is data or an action or both?
 6 |   void bar() {
 7 |   }
 8 | }
 9 | 
10 | 11 |

12 | This rule is deprecated, use {rule:java:S1845} instead. 13 |

14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidFieldNameMatchingTypeName.html: -------------------------------------------------------------------------------- 1 | It is somewhat confusing to have a field name matching the declaring class name. This probably means that type and or field names could be more precise. Example : 2 |
 3 | public class Foo extends Bar {
 4 |   // There's probably a better name for foo
 5 |   int foo;
 6 | }
 7 | 
8 | 9 |

10 | This rule is deprecated, use {rule:java:S1700} instead. 11 |

12 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidFinalLocalVariable.html: -------------------------------------------------------------------------------- 1 | Avoid using final local variables, turn them into fields. Example : 2 |
3 | public class MyClass {
4 |     public void foo() {
5 |         final String finalLocalVariable;
6 |     }
7 | }
8 |   
9 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidInstanceofChecksInCatchClause.html: -------------------------------------------------------------------------------- 1 | Each caught exception type should be handled in its own catch clause. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1193} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidInstantiatingObjectsInLoops.html: -------------------------------------------------------------------------------- 1 | Detects when a new object is created inside a loop 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidLiteralsInIfCondition.html: -------------------------------------------------------------------------------- 1 | Avoid using hard coded literals in conditional statements, declare those as static variables or private members. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S109} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidLosingExceptionInformation.html: -------------------------------------------------------------------------------- 1 | Statements in a catch block that invoke accessors on the exception without using the information only add to code size. Either remove the invocation, or use the return result. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1166} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidPrintStackTrace.html: -------------------------------------------------------------------------------- 1 | Avoid printStackTrace(); use a logger call instead. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1148} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidProtectedFieldInFinalClass.html: -------------------------------------------------------------------------------- 1 | Do not use protected fields in final classes since they cannot be subclassed. Clarify your intent by using private or package access modifiers instead. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S2156} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidReassigningParameters.html: -------------------------------------------------------------------------------- 1 | Reassigning values to parameters is a questionable practice. Use a temporary local variable instead. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1226} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidRethrowingException.html: -------------------------------------------------------------------------------- 1 | Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1166} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidStringBufferField.html: -------------------------------------------------------------------------------- 1 | StringBuffers can grow quite a lot, and so may become a source of memory leak (if the owning class has a long life time). Example : 2 |
 3 | class Foo {
 4 |   private StringBuffer memoryLeak;
 5 | }
 6 | 
7 | 8 |

9 | This rule is deprecated, use {rule:java:S1149} instead. 10 |

11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidSynchronizedAtMethodLevel.html: -------------------------------------------------------------------------------- 1 | Method level synchronization can backfire when new code is added to the method. Block-level synchronization helps to ensure that only the code that needs synchronization gets it. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidThreadGroup.html: -------------------------------------------------------------------------------- 1 | Avoid using ThreadGroup; although it is intended to be used in a threaded environment it contains methods that are not thread safe. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidThrowingNullPointerException.html: -------------------------------------------------------------------------------- 1 | Avoid throwing a NullPointerException - it's confusing because most people will assume that the virtual machine threw it. Consider using an IllegalArgumentException instead; this will be clearly seen as a programmer-initiated exception. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1695} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidThrowingRawExceptionTypes.html: -------------------------------------------------------------------------------- 1 |

2 | Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable, Exception, or Error, use 3 | a subclassed exception or error instead. 4 |

5 | 6 |

7 | This rule is deprecated, use {rule:java:S112} instead. 8 |

9 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidUsingHardCodedIP.html: -------------------------------------------------------------------------------- 1 | An application with hard-coded IP addresses can become impossible to deploy in some cases. Externalizing IP addresses is preferable. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1313} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidUsingNativeCode.html: -------------------------------------------------------------------------------- 1 | As JVM and Java language offer already many help in creating application, it should be very rare to have to rely on non-java code. Even though, it is rare to actually have to use Java Native Interface (JNI). As the use of JNI make application less portable, and harder to maintain, it is not recommended. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidUsingOctalValues.html: -------------------------------------------------------------------------------- 1 | Integer literals should not start with zero. Zero means that the rest of literal will be interpreted as an octal value. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1314} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidUsingShortType.html: -------------------------------------------------------------------------------- 1 | Java uses the short type to reduce memory usage, not to optimize calculation. On the contrary, the JVM does not have arithmetic capabilities with the type short. So, the P-code must convert the short into int, then do the proper calculation and then again, convert int to short. So, use of the short type may have a great effect on memory usage. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidUsingVolatile.html: -------------------------------------------------------------------------------- 1 | Use of the keyword "volatile" is general used to fine tune a Java application, and therefore, requires a good expertise of the Java Memory Model. Morover, its range of action is somewhat misknown. Therefore, the volatile keyword should not be used for maintenance purpose and portability. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/BadComparison.html: -------------------------------------------------------------------------------- 1 | Avoid equality comparisons with Double.NaN - these are likely to be logic errors. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/BeanMembersShouldSerialize.html: -------------------------------------------------------------------------------- 1 | If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable. Member variables need to be marked as transient, static, or have accessor methods in the class. Marking variables as transient is the safest and easiest modification. Accessor methods should follow the Java naming conventions, i.e.if you have a variable foo, you should provide getFoo and setFoo methods. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/BigIntegerInstantiation.html: -------------------------------------------------------------------------------- 1 | Don't create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) and for 1.5 on, BigInteger.TEN and BigDecimal (BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN) 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/BooleanGetMethodName.html: -------------------------------------------------------------------------------- 1 | Looks for methods named "getX()" with "boolean" as the return type. The convention is to name these methods "isX()". 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/BooleanInstantiation.html: -------------------------------------------------------------------------------- 1 | Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boolean.valueOf() instead. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/BrokenNullCheck.html: -------------------------------------------------------------------------------- 1 | The null check is broken since it will throw a Nullpointer itself. The reason is that a method is called on the object when it is null. It is likely that you used || instead of && or vice versa. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1697} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ByteInstantiation.html: -------------------------------------------------------------------------------- 1 | In JDK 1.5, calling new Byte() causes memory allocation. Byte.valueOf() is more memory friendly. Example : 2 |
3 | public class Foo {
4 | private Byte i = new Byte(0); // change to Byte i =
5 | Byte.valueOf(0);
6 | }
7 | 
8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CallSuperFirst.html: -------------------------------------------------------------------------------- 1 | Super should be called at the start of the method. Example : 2 |
 3 | public class DummyActivity extends Activity {
 4 |   public void onCreate(Bundle bundle) {
 5 |     // missing call to super.onCreate(bundle)
 6 |     foo();
 7 |   }
 8 | }
 9 | 
10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CallSuperInConstructor.html: -------------------------------------------------------------------------------- 1 | It is a good practice to call super() in a constructor. If super() is not called but another constructor (such as an overloaded constructor) is called, this rule will not report it. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CallSuperLast.html: -------------------------------------------------------------------------------- 1 | Super should be called at the end of the method. Example : 2 |
 3 | public class DummyActivity extends Activity {
 4 |   public void onPause() {
 5 |     foo();
 6 |     // missing call to super.onPause()
 7 |   }
 8 | }
 9 | 
10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CheckResultSet.html: -------------------------------------------------------------------------------- 1 | Always check the return of one of the navigation method (next,previous,first,last) of a ResultSet. Indeed, if the value return is "false", the developer should deal with it ! 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ClassCastExceptionWithToArray.html: -------------------------------------------------------------------------------- 1 | if you need to get an array of a class from your Collection, you should pass an array of the desidered class as the parameter of the toArray method. Otherwise you will get a ClassCastException. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ClassNamingConventions.html: -------------------------------------------------------------------------------- 1 |

2 | Class names should always begin with an upper case character. 3 |

4 | 5 |

6 | This rule is deprecated, use {rule:java:S101} and {rule:java:S114} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ClassWithOnlyPrivateConstructorsShouldBeFinal.html: -------------------------------------------------------------------------------- 1 | A class with only private constructors should be final, unless the private constructor is called by a inner class. Example : 2 |
 3 | public class Foo {  //Should be final
 4 |     private Foo() { }
 5 | }
 6 | 
7 | 8 |

9 | This rule is deprecated, use {rule:java:S2974} instead. 10 |

11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CloneMethodMustImplementCloneable.html: -------------------------------------------------------------------------------- 1 | The method clone() should only be implemented if the class implements the Cloneable interface with the exception of a final method that only throws CloneNotSupportedException. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1182} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CloneThrowsCloneNotSupportedException.html: -------------------------------------------------------------------------------- 1 | The method clone() should throw a CloneNotSupportedException. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1182} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CloseResource.html: -------------------------------------------------------------------------------- 1 | Ensure that resources (like Connection, Statement, and ResultSet objects) are always closed after use. It does this by looking for code patterned like : 2 |
 3 | Connection c = openConnection();
 4 | try {
 5 |   // do stuff, and maybe catch something
 6 | } finally {
 7 |   c.close();
 8 | }
 9 | 
10 | 11 |

12 | This rule is deprecated, use {rule:java:S2095} instead. 13 |

14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CollapsibleIfStatements.html: -------------------------------------------------------------------------------- 1 | Sometimes two 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1066} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CommentContent.html: -------------------------------------------------------------------------------- 1 | A rule for the politically correct... we don't want to offend anyone. Example: 2 |
3 | // OMG, this is horrible, Bob is an idiot !!!
4 | 
5 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CommentRequired.html: -------------------------------------------------------------------------------- 1 | Denotes whether comments are required (or unwanted) for specific language elements. Example: 2 |
3 | /**
4 | * 
5 | *
6 | * @author George Bush
7 | */
8 | 
9 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CommentSize.html: -------------------------------------------------------------------------------- 1 | Determines whether the dimensions of non-header comments found are within the specified limits. Example: 2 |
 3 | /**
 4 | *
 5 | * too many lines!
 6 | *
 7 | *
 8 | *
 9 | *
10 | *
11 | *
12 | *
13 | *
14 | *
15 | *
16 | *
17 | *
18 | */
19 | 
20 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CompareObjectsWithEquals.html: -------------------------------------------------------------------------------- 1 | Use equals() to compare object references; avoid comparing them with ==. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1698} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ConfusingTernary.html: -------------------------------------------------------------------------------- 1 | In an if expression with an else clause, avoid negation in the test. For example, rephrase: if (x != y) diff(); else same(); as: if (x == y) same(); else diff(); Most if (x != y) cases without an else are often return cases, so consistent use of this rule makes the code easier to read. Also, this resolves trivial ordering problems, such as does the error case go first? or does the common case go first?. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ConsecutiveAppendsShouldReuse.html: -------------------------------------------------------------------------------- 1 | Consecutively calls to StringBuffer/StringBuilder .append should reuse the target object. This can improve the performance. Example: 2 |
 3 | String foo = " ";
 4 | 
 5 | StringBuffer buf = new StringBuffer();
 6 | buf.append("Hello"); // poor
 7 | buf.append(foo);
 8 | buf.append("World");
 9 | 
10 | StringBuffer buf = new StringBuffer();
11 | buf.append("Hello").append(foo).append("World"); // good
12 | 
13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ConsecutiveLiteralAppends.html: -------------------------------------------------------------------------------- 1 | Consecutively calling StringBuffer.append with String literals 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CouplingBetweenObjects.html: -------------------------------------------------------------------------------- 1 | This rule counts unique attributes, local variables and return types within an object. A number higher than specified threshold can indicate a high degree of coupling. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1200} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/CyclomaticComplexity.html: -------------------------------------------------------------------------------- 1 |

2 | Complexity is determined by the number of decision points in a method plus one for the method entry. The decision 3 | points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate 4 | complexity, 8-10 is high complexity, and 11+ is very high complexity. 5 |

6 | 7 |

8 | This rule is deprecated, use {rule:java:MethodCyclomaticComplexity} or {rule:java:ClassCyclomaticComplexity} 9 | instead. 10 |

11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DefaultLabelNotLastInSwitchStmt.html: -------------------------------------------------------------------------------- 1 | Switch statements should have a default label. Example : 2 |
 3 | public class Foo {
 4 |  void bar(int a) {
 5 |   switch (a) {
 6 |    case 1:  // do something
 7 |       break;
 8 |    default:  // the default case should be last, by convention
 9 |       break;
10 |    case 2:
11 |       break;
12 |   }
13 |  }
14 | }
15 |   
16 | 17 |

18 | This rule is deprecated, use {rule:java:SwitchLastCaseIsDefaultCheck} instead. 19 |

20 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DefaultPackage.html: -------------------------------------------------------------------------------- 1 | Use explicit scoping instead of the default package private level. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DoNotCallSystemExit.html: -------------------------------------------------------------------------------- 1 | Web applications should not call System.exit(), since only the web container or the application server should stop the JVM. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1147} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DoNotExtendJavaLangError.html: -------------------------------------------------------------------------------- 1 | Errors are system exceptions. Do not extend them. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1194} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DoNotHardCodeSDCard.html: -------------------------------------------------------------------------------- 1 | Use Environment.getExternalStorageDirectory() instead of "/sdcard". 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DoNotUseThreads.html: -------------------------------------------------------------------------------- 1 | The J2EE specification explicitly forbid use of threads. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DontCallThreadRun.html: -------------------------------------------------------------------------------- 1 | Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1217} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DontImportJavaLang.html: -------------------------------------------------------------------------------- 1 | Avoid importing anything from the package 'java.lang'. These classes are automatically imported (JLS 7.5.3). 2 | 3 |

4 | This rule is deprecated, use {rule:java:UselessImportCheck} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DontImportSun.html: -------------------------------------------------------------------------------- 1 | Avoid importing anything from the 'sun.*' packages. These packages are not portable and are likely to change. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1191} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/DuplicateImports.html: -------------------------------------------------------------------------------- 1 | Avoid duplicate import statements. 2 | 3 |

4 | This rule is deprecated, use {rule:java:UselessImportCheck} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyCatchBlock.html: -------------------------------------------------------------------------------- 1 |

2 | Empty Catch Block finds instances where an exception is caught, but nothing is done. In most circumstances, this 3 | swallows an exception which should either be acted on or reported. 4 |

5 | 6 |

7 | This rule is deprecated, use {rule:java:S108} instead. 8 |

9 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyFinalizer.html: -------------------------------------------------------------------------------- 1 |

If the finalize() method is empty, then it does not need to exist.

2 | 3 |

4 | This rule is deprecated, use {rule:java:S1186} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyFinallyBlock.html: -------------------------------------------------------------------------------- 1 |

2 | Avoid empty finally blocks - these can be deleted. 3 |

4 | 5 |

6 | This rule is deprecated, use {rule:java:S108} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyIfStmt.html: -------------------------------------------------------------------------------- 1 |

2 | Empty If Statement finds instances where a condition is checked but nothing is done about it. 3 |

4 | 5 |

6 | This rule is deprecated, use {rule:java:S108} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyInitializer.html: -------------------------------------------------------------------------------- 1 | An empty initializer was found. Example : 2 |
 3 | public class Foo {
 4 | 
 5 |    static {} // Why ?
 6 | 
 7 |    {} // Again, why ?
 8 | 
 9 | }
10 | 
11 | 12 |

13 | This rule is deprecated, use {rule:java:S108} instead. 14 |

15 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyMethodInAbstractClassShouldBeAbstract.html: -------------------------------------------------------------------------------- 1 | An empty method in an abstract class should be abstract instead, as developer may rely on this empty implementation rather than code the appropriate one. 2 |
 3 | public abstract class ShouldBeAbstract
 4 | {
 5 |   public Object couldBeAbstract()
 6 |   {
 7 |   // Should be abstract method ?
 8 |     return null;
 9 |   }
10 | 
11 |   public void couldBeAbstract()
12 |   {
13 |   }
14 | }
15 | 
16 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyStatementBlock.html: -------------------------------------------------------------------------------- 1 | Empty block statements serve no purpose and should be removed. Example: 2 |
 3 | public class Foo {
 4 | 
 5 |    private int _bar;
 6 | 
 7 |    public void setBar(int bar) {
 8 |       { _bar = bar; } // Why not?
 9 |       {} // But remove this.
10 |    }
11 | 
12 | }
13 | 
14 | 15 |

16 | This rule is deprecated, use {rule:java:S108} instead. 17 |

18 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyStatementNotInLoop.html: -------------------------------------------------------------------------------- 1 | An empty statement (aka a semicolon by itself) that is not used as the sole body of a for loop or while loop is probably a bug. It could also be a double semicolon, which is useless and should be removed. 2 | 3 |

4 | This rule is deprecated, use {rule:java:EmptyStatementUsageCheck} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyStaticInitializer.html: -------------------------------------------------------------------------------- 1 | An empty static initializer was found. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S108} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptySwitchStatements.html: -------------------------------------------------------------------------------- 1 | Avoid empty switch statements. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S108} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptySynchronizedBlock.html: -------------------------------------------------------------------------------- 1 | Avoid empty synchronized blocks - they're useless. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S108} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyTryBlock.html: -------------------------------------------------------------------------------- 1 | Avoid empty try blocks - what's the point? 2 | 3 |

4 | This rule is deprecated, use {rule:java:S108} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EmptyWhileStmt.html: -------------------------------------------------------------------------------- 1 | Empty While Statement finds all instances where a while statement does nothing. If it is a timing loop, then you should use Thread.sleep() for it; if it's a while loop that does a lot in the exit expression, rewrite it to make it clearer. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S108} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/EqualsNull.html: -------------------------------------------------------------------------------- 1 | Inexperienced programmers sometimes confuse comparison concepts and use equals() to compare to null. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S2159} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ExceptionAsFlowControl.html: -------------------------------------------------------------------------------- 1 | Using Exceptions as flow control leads to GOTOish code and obscures true exceptions when debugging. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1141} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ExcessiveClassLength.html: -------------------------------------------------------------------------------- 1 | Long Class files are indications that the class may be trying to do too much. Try to break it down, and reduce the size to something manageable. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1448} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ExcessiveImports.html: -------------------------------------------------------------------------------- 1 | A high number of imports can indicate a high degree of coupling within an object. Rule counts the number of unique imports and reports a violation if the count is above the user defined threshold. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1200} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ExcessiveMethodLength.html: -------------------------------------------------------------------------------- 1 | Violations of this rule usually indicate that the method is doing too much. Try to reduce the method size by creating helper methods and removing any copy/pasted code. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S138} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ExcessiveParameterList.html: -------------------------------------------------------------------------------- 1 |

2 | Long parameter lists can indicate that a new object should be created to wrap the numerous parameters. Basically, try 3 | to group the parameters together. 4 |

5 | 6 |

7 | This rule is deprecated, use {rule:java:S107} instead. 8 |

9 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ExcessivePublicCount.html: -------------------------------------------------------------------------------- 1 | A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1448} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ExtendsObject.html: -------------------------------------------------------------------------------- 1 | No need to explicitly extend Object. Example: 2 |
 3 | public class Foo extends Object { // not required
 4 | }
 5 | 
6 | 7 |

8 | This rule is deprecated, use {rule:java:S1939} instead. 9 |

10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/FinalFieldCouldBeStatic.html: -------------------------------------------------------------------------------- 1 | If a final field is assigned to a compile-time constant, it could be made static, thus saving overhead in each object at runtime. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1170} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/FinalizeDoesNotCallSuperFinalize.html: -------------------------------------------------------------------------------- 1 | If the finalize() is implemented, its last action should be to call super.finalize. 2 | 3 |

4 | This rule is deprecated, use {rule:java:ObjectFinalizeOverridenCallsSuperFinalizeCheck} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/FinalizeOnlyCallsSuperFinalize.html: -------------------------------------------------------------------------------- 1 | If the finalize() is implemented, it should do something besides just calling super.finalize(). 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1185} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/FinalizeOverloaded.html: -------------------------------------------------------------------------------- 1 | Methods named finalize() should not have parameters. It is confusing and probably a bug to overload finalize(). It will not be called by the VM. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1175} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/FinalizeShouldBeProtected.html: -------------------------------------------------------------------------------- 1 | If you override finalize(), make it protected. If you make it public, other classes may call it. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1174} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ForLoopShouldBeWhileLoop.html: -------------------------------------------------------------------------------- 1 | Some for loops can be simplified to while loops - this makes them more concise. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1264} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ForLoopsMustUseBraces.html: -------------------------------------------------------------------------------- 1 |

2 | Avoid using 'for' statements without using curly braces, like for (int i=0; i<42;i++) foo(); 3 |

4 | 5 |

6 | This rule is deprecated, use {rule:java:S121} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/GenericsNaming.html: -------------------------------------------------------------------------------- 1 | Generics names should be a one letter long and upper case. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S119} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/GuardDebugLogging.html: -------------------------------------------------------------------------------- 1 | When log messages are composed by concatenating strings, the whole section should be guarded by a isDebugEnabled() check to avoid performance and memory issues. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/GuardLogStatement.html: -------------------------------------------------------------------------------- 1 | Whenever using a log level, one should check if the loglevel is actually enabled, or 2 | otherwise skip the associate String creation and manipulation. Example: 3 |
4 | // Add this for performance
5 | if (log.isDebugEnabled() { ...
6 |   log.debug("This happens");
7 | 
8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/GuardLogStatementJavaUtil.html: -------------------------------------------------------------------------------- 1 | Whenever using a log level, one should check if the loglevel is actually enabled, or 2 | otherwise skip the associate String creation and manipulation. Example: 3 |
4 | // Add this for performance
5 | if (log.isLoggable(Level.FINE)) { ...
6 |   log.fine("This happens");
7 | 
8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/IdempotentOperations.html: -------------------------------------------------------------------------------- 1 | Avoid idempotent operations - they are have no effect. Example :
int x = 2;
x = x;
2 | 3 |

4 | This rule is deprecated, use {rule:java:S1656} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/IfElseStmtsMustUseBraces.html: -------------------------------------------------------------------------------- 1 |

2 | Avoid using if..else statements without using curly braces. 3 |

4 | 5 |

6 | This rule is deprecated, use {rule:java:S121} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/IfStmtsMustUseBraces.html: -------------------------------------------------------------------------------- 1 |

2 | Avoid using if statements without using curly braces. 3 |

4 | 5 |

6 | This rule is deprecated, use {rule:java:S121} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ImmutableField.html: -------------------------------------------------------------------------------- 1 | Identifies private fields whose values never change once they are initialized either in the declaration of the field or by a constructor. This aids in converting existing classes to immutable classes. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ImportFromSamePackage.html: -------------------------------------------------------------------------------- 1 | No need to import a type that lives in the same package. 2 | 3 |

4 | This rule is deprecated, use {rule:java:UselessImportCheck} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/InefficientEmptyStringCheck.html: -------------------------------------------------------------------------------- 1 | String.trim().length() is an inefficient way to check if a String is really empty, as it creates a new String object just to check its size. Consider creating a static function that loops through a string, checking Character.isWhitespace() on each character and returning false if a non-whitespace character is found. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/InefficientStringBuffering.html: -------------------------------------------------------------------------------- 1 | Avoid concatenating non literals in a StringBuffer constructor or append(). 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/InstantiationToGetClass.html: -------------------------------------------------------------------------------- 1 | Avoid instantiating an object just to call getClass() on it; use the .class public member instead. Example : replace 2 | Class c = new String().getClass(); with Class c = String.class; 3 | 4 |

5 | This rule is deprecated, use {rule:java:S2133} instead. 6 |

7 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/InsufficientStringBufferDeclaration.html: -------------------------------------------------------------------------------- 1 | Failing to pre-size a StringBuffer properly could cause it to re-size many times during runtime. This rule checks the characters that are actually passed into StringBuffer.append(), but represents a best guess worst case scenario. An empty StringBuffer constructor initializes the object to 16 characters. This default is assumed if the length of the constructor can not be determined. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/IntegerInstantiation.html: -------------------------------------------------------------------------------- 1 | In JDK 1.5, calling new Integer() causes memory allocation. Integer.valueOf() is more memory friendly. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/JumbledIncrementer.html: -------------------------------------------------------------------------------- 1 | Avoid jumbled loop incrementers - it's usually a mistake, and it's confusing even if it's what's intended. 2 |
Example : 3 |
 4 | public class JumbledIncrementerRule1 {
 5 |   public void foo() {
 6 |    for (int i = 0; i < 10; i++) {
 7 |     for (int k = 0; k < 20; i++) {
 8 |      System.out.println("Hello");
 9 |     }
10 |    }
11 |   }
12 | }
13 | 14 |

15 | This rule is deprecated, use {rule:java:ForLoopCounterChangedCheck} instead. 16 |

17 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/LocalHomeNamingConvention.html: -------------------------------------------------------------------------------- 1 | The Local Home interface of a Session EJB should be suffixed by "LocalHome". 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/LocalInterfaceSessionNamingConvention.html: -------------------------------------------------------------------------------- 1 | The Local Interface of a Session EJB should be suffixed by "Local". 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/LocalVariableCouldBeFinal.html: -------------------------------------------------------------------------------- 1 | A local variable assigned only once can be declared final. Example : 2 |
 3 | public class Bar {
 4 |  public void foo () {
 5 |   String a = "a"; //if a will not be assigned again it is better to do this:
 6 |   final String b = "b";
 7 |  }
 8 | }
 9 |   
10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/LoggerIsNotStaticFinal.html: -------------------------------------------------------------------------------- 1 | In most cases, the Logger can be declared static and final. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1312} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/LogicInversion.html: -------------------------------------------------------------------------------- 1 | Use opposite operator instead of negating the whole expression with a logic complement operator. Example: 2 |
 3 | public boolean bar(int a, int b) {
 4 | 
 5 |   if (!(a == b)) // use !=
 6 |     return false;
 7 | 
 8 |   if (!(a < b)) // use >=
 9 |     return false;
10 | 
11 |   return true;
12 | }
13 | 
14 | 15 |

16 | This rule is deprecated, use {rule:java:S1940} instead. 17 |

18 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/LongInstantiation.html: -------------------------------------------------------------------------------- 1 | In JDK 1.5, calling new Long() causes memory allocation. Long.valueOf() is more memory friendly. Example : 2 |
3 | public class Foo {
4 | private Long i = new Long(0); // change to Long i =
5 | Long.valueOf(0);
6 | }
7 |   
8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/LongVariable.html: -------------------------------------------------------------------------------- 1 | Detects when a field, formal or local variable is declared with a long name. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S117} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/LooseCoupling.html: -------------------------------------------------------------------------------- 1 | Avoid using implementation types (i.e., HashSet); use the interface (i.e, Set) instead 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1319} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/LoosePackageCoupling.html: -------------------------------------------------------------------------------- 1 | Avoid using classes from the configured package hierarchy outside of the package hierarchy, 2 | except when using one of the configured allowed classes. Example: 3 |
 4 | package some.package;
 5 | 
 6 | import some.other.package.subpackage.subsubpackage.DontUseThisClass;
 7 | 
 8 | public class Bar {
 9 |    DontUseThisClass boo = new DontUseThisClass();
10 | }
11 | 
12 | 13 |

14 | This rule is deprecated, use {rule:java:ArchitecturalConstraint} instead. 15 |

16 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MDBAndSessionBeanNamingConvention.html: -------------------------------------------------------------------------------- 1 | The EJB Specification state that any MessageDrivenBean or SessionBean should be suffixed by Bean. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MethodArgumentCouldBeFinal.html: -------------------------------------------------------------------------------- 1 | A method argument that is never assigned can be declared final. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1226} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MethodNamingConventions.html: -------------------------------------------------------------------------------- 1 | Method names should always begin with a lower case character, and should not contain underscores. Example : 2 |
 3 | public class Foo {
 4 |   public void fooStuff() {
 5 |   }
 6 | }
 7 | 
8 | 9 |

10 | This rule is deprecated, use {rule:java:S100} instead. 11 |

12 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MethodReturnsInternalArray.html: -------------------------------------------------------------------------------- 1 | Exposing internal arrays directly allows the user to modify some code that could be critical. It is safer to return a copy of the array. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S2384} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MethodWithSameNameAsEnclosingClass.html: -------------------------------------------------------------------------------- 1 | Non-constructor methods should not have the same name as the enclosing class. Example : 2 |
 3 | public class MyClass {
 4 |   // this is bad because it is a method
 5 |   public void MyClass() {}
 6 |   // this is OK because it is a constructor
 7 |   public MyClass() {}
 8 | }
 9 | 
10 | 11 |

12 | This rule is deprecated, use {rule:java:S1223} instead. 13 |

14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MisleadingVariableName.html: -------------------------------------------------------------------------------- 1 | Detects when a non-field has a name starting with 'm_'. This usually indicates a field and thus is confusing. Example : 2 |
 3 | public class Foo {
 4 |   private int m_foo; // OK
 5 |   public void bar(String m_baz) {  // Bad
 6 |     int m_boz = 42; // Bad
 7 |   }
 8 | }
 9 | 
10 | 11 |

12 | This rule is deprecated, use {rule:java:S117} instead. 13 |

14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MisplacedNullCheck.html: -------------------------------------------------------------------------------- 1 | The null check here is misplaced. if the variable is null you'll get a NullPointerException. 2 | Either the check is useless (the variable will never be null) or it's incorrect. 3 |
Example : 4 |
 5 | if (object1!=null && object2.equals(object1)) {
 6 |   ...
 7 | }
 8 | 
9 | 10 |

11 | This rule is deprecated, use {rule:java:S1697} or {rule:java:S2259} instead. 12 |

13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MissingBreakInSwitch.html: -------------------------------------------------------------------------------- 1 | A switch statement without an enclosed break statement may be a bug. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S128} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MissingSerialVersionUID.html: -------------------------------------------------------------------------------- 1 | Classes that are serializable should provide a serialVersionUID field. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S2057} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MissingStaticMethodInNonInstantiatableClass.html: -------------------------------------------------------------------------------- 1 | A class that has private constructors and does not have any static methods or fields cannot be used. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/MoreThanOneLogger.html: -------------------------------------------------------------------------------- 1 | Normally only one logger is used in each class. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1312} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/NPathComplexity.html: -------------------------------------------------------------------------------- 1 | The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity. Example : 2 |
3 | public class Foo {
4 |   void bar() {
5 |    // lots of complicated code
6 |   }
7 |  }
8 | 
9 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/NcssConstructorCount.html: -------------------------------------------------------------------------------- 1 | This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given constructor. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S138} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/NcssMethodCount.html: -------------------------------------------------------------------------------- 1 | This rule uses the NCSS (Non Commenting Source Statements) algorithm to determine the number of lines of code for a given method. NCSS ignores comments, and counts actual statements. Using this algorithm, lines of code that are split are counted as one. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S138} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/NoPackage.html: -------------------------------------------------------------------------------- 1 | Detects when a class or interface does not have a package definition. Example : 2 |
 3 | // no package declaration
 4 | public class ClassInDefaultPackage {
 5 | }
 6 |   
7 | 8 |

9 | This rule is deprecated, use {rule:java:S1220} instead. 10 |

11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/NonCaseLabelInSwitchStatement.html: -------------------------------------------------------------------------------- 1 | A non-case label (e.g. a named break/continue label) was present in a switch statement. This legal, but confusing. It is easy to mix up the case labels and the non-case labels. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1219} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/NonStaticInitializer.html: -------------------------------------------------------------------------------- 1 | A nonstatic initializer block will be called any time a constructor is invoked (just prior to invoking the constructor). While this is a valid language construct, it is rarely used and is confusing. Example : 2 |
public class MyClass {
// this block gets run before any call to a constructor {
System.out.println("I 3 | am about to construct myself");
}
}
4 | 5 |

6 | This rule is deprecated, use {rule:java:S1171} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/NonThreadSafeSingleton.html: -------------------------------------------------------------------------------- 1 | Non-thread safe singletons can result in bad state changes. Eliminate static singletons if possible by instantiating the object directly. Static singletons are usually not needed as only a single instance exists anyway. Other possible fixes are to synchronize the entire method or to use an initialize-on-demand holder class (do not use the double-check idiom). See Effective Java, item 48. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S2444} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/NullAssignment.html: -------------------------------------------------------------------------------- 1 | Assigning a null to a variable (outside of its declaration) is usually bad form. Some times, the assignment is an indication that the programmer doesn't completely understand what is going on in the code. NOTE: This sort of assignment may in rare cases be useful to encourage garbage collection. If that's what you're using it for, by all means, disregard this rule :-) 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/OneDeclarationPerLine.html: -------------------------------------------------------------------------------- 1 | Java allows the use of several variables declaration of the same type on one line. However, it 2 | can lead to quite messy code. This rule looks for several declarations on the same line. Example: 3 |
 4 | String name; // separate declarations
 5 | String lastname;
 6 | 
 7 | String name, lastname; // combined declaration, a violation
 8 | 
9 | 10 |

11 | This rule is deprecated, use {rule:java:S122} instead. 12 |

13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/OnlyOneReturn.html: -------------------------------------------------------------------------------- 1 | A method should have only one exit point, and that should be the last statement in the method. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1142} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/PackageCase.html: -------------------------------------------------------------------------------- 1 | Detects when a package definition contains upper case characters. Example : 2 |
 3 | package com.MyCompany;  // <- should be lower case name
 4 | public class SomeClass {
 5 | }
 6 | 
7 | 8 |

9 | This rule is deprecated, use {rule:java:S120} instead. 10 |

11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/PositionLiteralsFirstInCaseInsensitiveComparisons.html: -------------------------------------------------------------------------------- 1 | Position literals first in comparisons, if the second argument is null then NullPointerExceptions 2 | can be avoided, they will just return false. Example: 3 |
 4 | class Foo {
 5 |   boolean bar(String x) {
 6 |     return x.equalsIgnoreCase("2"); // should be "2".equalsIgnoreCase(x)
 7 |   }
 8 | }
 9 | 
10 | 11 |

12 | This rule is deprecated, use {rule:java:S1132} instead. 13 |

14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/PositionLiteralsFirstInComparisons.html: -------------------------------------------------------------------------------- 1 | Position literals first in String comparisons - that way if the String is null you won't get a NullPointerException, it'll just return false. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1132} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/PreserveStackTrace.html: -------------------------------------------------------------------------------- 1 | Throwing a new exception from a catch block without passing the original exception into the new Exception will cause the true stack trace to be lost, and can make it difficult to debug effectively. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1166} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ProperCloneImplementation.html: -------------------------------------------------------------------------------- 1 | Object clone() should be implemented with super.clone(). Example : 2 |
 3 | class Foo{
 4 |     public Object clone(){
 5 |         return new Foo(); // This is bad
 6 |     }
 7 | }
 8 |   
9 | 10 |

11 | This rule is deprecated, use {rule:java:S1182} instead. 12 |

13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ProperLogger.html: -------------------------------------------------------------------------------- 1 | Logger should normally be defined private static final and have the correct class. Private final Log log; is also allowed for rare cases when loggers need to be passed around, but the logger needs to be passed into the constructor. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1312} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/RemoteInterfaceNamingConvention.html: -------------------------------------------------------------------------------- 1 | Remote Interface of a Session EJB should NOT be suffixed. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/RemoteSessionInterfaceNamingConvention.html: -------------------------------------------------------------------------------- 1 | Remote Home interface of a Session EJB should be suffixed by "Home". 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ReplaceEnumerationWithIterator.html: -------------------------------------------------------------------------------- 1 | Consider replacing this Enumeration with the newer java.util.Iterator 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1150} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ReplaceHashtableWithMap.html: -------------------------------------------------------------------------------- 1 | Consider replacing this Hashtable with the newer java.util.Map 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1149} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ReplaceVectorWithList.html: -------------------------------------------------------------------------------- 1 | Consider replacing Vector usages with the newer java.util.ArrayList if expensive threadsafe operation is not required. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1149} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ReturnFromFinallyBlock.html: -------------------------------------------------------------------------------- 1 | Avoid returning from a finally block - this can discard exceptions. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1143} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ShortClassName.html: -------------------------------------------------------------------------------- 1 | Classnames with fewer than five characters are not recommended. Example: 2 |
 3 | public class Foo {
 4 | }
 5 | 
6 | 7 |

8 | This rule is deprecated, use {rule:java:S101} instead. 9 |

10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ShortInstantiation.html: -------------------------------------------------------------------------------- 1 | In JDK 1.5, calling new Short() causes memory allocation. Short.valueOf() is more memory friendly. Example : 2 |
3 | public class Foo {
4 | private Short i = new Short(0); // change to Short i =
5 | Short.valueOf(0);
6 | }
7 |   
8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ShortMethodName.html: -------------------------------------------------------------------------------- 1 | Detects when very short method names are used. Example : 2 |
 3 | public class ShortMethod {
 4 |   public void a( int i ) { // Violation
 5 |   }
 6 | }
 7 | 
8 | 9 |

10 | This rule is deprecated, use {rule:java:S100} instead. 11 |

12 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/ShortVariable.html: -------------------------------------------------------------------------------- 1 | Detects when a field, local, or parameter has a very short name. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S117} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SignatureDeclareThrowsException.html: -------------------------------------------------------------------------------- 1 | It is unclear which exceptions that can be thrown from the methods. It might be difficult to document and understand the vague interfaces. Use either a class derived from RuntimeException or a checked exception. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S112} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SignatureDeclareThrowsExceptionWithTypeResolution.html: -------------------------------------------------------------------------------- 1 | It is unclear which exceptions that can be thrown from the methods. 2 | It might be difficult to document and understand the vague interfaces. 3 | Use either a class derived from RuntimeException or a checked exception. 4 | 5 | JUnit classes are excluded. Example: 6 |
 7 | public void methodThrowingException() throws Exception {
 8 | }
 9 | 
10 | 11 |

12 | This rule is deprecated, use {rule:java:S112} instead. 13 |

14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SimpleDateFormatNeedsLocale.html: -------------------------------------------------------------------------------- 1 | Be sure to specify a Locale when creating a new instance of SimpleDateFormat. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SimplifyBooleanExpressions.html: -------------------------------------------------------------------------------- 1 | Avoid unnecessary comparisons in boolean expressions - this complicates simple code. Example : 2 |
 3 | public class Bar {
 4 |  // can be simplified to
 5 |  // bar = isFoo();
 6 |  private boolean bar = (isFoo() == true);
 7 | 
 8 |  public isFoo() { return false;}
 9 | }
10 | 
11 | 12 |

13 | This rule is deprecated, use {rule:java:S1125} instead. 14 |

15 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SimplifyConditional.html: -------------------------------------------------------------------------------- 1 | No need to check for null before an instanceof; the instanceof keyword returns false when given a null argument. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SimplifyStartsWith.html: -------------------------------------------------------------------------------- 1 | Since it passes in a literal of length 1, this call to String.startsWith can be rewritten using String.charAt(0) to save some time. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SingularField.html: -------------------------------------------------------------------------------- 1 | A field that's only used by one method could perhaps be replaced by a local variable. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/StaticEJBFieldShouldBeFinal.html: -------------------------------------------------------------------------------- 1 | According to the J2EE specification (p.494), an EJB should not have any static fields with write access. However, static read only fields are allowed. This ensures proper behavior especially when instances are distributed by the container on several JREs. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/StringBufferInstantiationWithChar.html: -------------------------------------------------------------------------------- 1 | StringBuffer sb = new StringBuffer('c'); The char will be converted into int to intialize StringBuffer size. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1317} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/StringInstantiation.html: -------------------------------------------------------------------------------- 1 | Avoid instantiating String objects; this is usually unnecessary. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/StringToString.html: -------------------------------------------------------------------------------- 1 | Avoid calling toString() on String objects; this is unnecessary. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1858} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SuspiciousConstantFieldName.html: -------------------------------------------------------------------------------- 1 | A field name is all in uppercase characters, which in Sun's Java naming conventions indicate a constant. However, the field is not final. Example : 2 |
 3 | public class Foo {
 4 |   // this is bad, since someone could accidentally
 5 |   // do PI = 2.71828; which is actualy e
 6 |   // final double PI = 3.16; is ok
 7 |   double PI = 3.16;
 8 | }
 9 | 
10 | 11 |

12 | This rule is deprecated, use {rule:java:S116} instead. 13 |

14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SuspiciousHashcodeMethodName.html: -------------------------------------------------------------------------------- 1 | The method name and return type are suspiciously close to hashCode(), which may mean you are intending to override the hashCode() method. Example : 2 |
 3 | public class Foo {
 4 |   public int hashcode() {
 5 |   // oops, this probably was supposed to be hashCode
 6 |   }
 7 | }
8 | 9 |

10 | This rule is deprecated, use {rule:java:S1221} instead. 11 |

12 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SuspiciousOctalEscape.html: -------------------------------------------------------------------------------- 1 | A suspicious octal escape sequence was found inside a String literal. The Java language specification (section 3.10.6) says an octal escape sequence inside a literal String shall consist of a backslash followed by: OctalDigit | OctalDigit OctalDigit | ZeroToThree OctalDigit OctalDigit Any octal escape sequence followed by non-octal digits can be confusing, e.g. "\038" is interpreted as the octal escape sequence "\03" followed by the literal character 8. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SwitchDensity.html: -------------------------------------------------------------------------------- 1 | A high ratio of statements to labels in a switch statement implies that the switch statement is doing too much work. Consider moving the statements into new methods, or creating subclasses based on the switch variable. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1151} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SwitchStmtsShouldHaveDefault.html: -------------------------------------------------------------------------------- 1 | Switch statements should have a default label. Example : 2 |
 3 | public class Foo {
 4 |  public void bar() {
 5 |   int x = 2;
 6 |   switch (x) {
 7 |    case 2: int j = 8;
 8 |   }
 9 |  }
10 | }
11 | 
12 | 13 |

14 | This rule is deprecated, use {rule:java:SwitchLastCaseIsDefaultCheck} instead. 15 |

16 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/SystemPrintln.html: -------------------------------------------------------------------------------- 1 | System.(out|err).print is used, consider using a logger. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S106} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/TooManyFields.html: -------------------------------------------------------------------------------- 1 | Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/TooManyMethods.html: -------------------------------------------------------------------------------- 1 | A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1448} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/TooManyStaticImports.html: -------------------------------------------------------------------------------- 1 | If you overuse the static import feature, it can make your program unreadable and unmaintainable, polluting its namespace with all the static members you import. Readers of your code (including you, a few months after you wrote it) will not know which class a static member comes from (Sun 1.5 Language Guide). 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UncommentedEmptyConstructor.html: -------------------------------------------------------------------------------- 1 | Uncommented Empty Constructor finds instances where a constructor does not contain statements, but there is no comment. By explicitly commenting empty constructors it is easier to distinguish between intentional (commented) and unintentional empty constructors. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S2094} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UncommentedEmptyMethodBody.html: -------------------------------------------------------------------------------- 1 |

Uncommented Empty Method finds instances where a method does not contain statements, but there is no comment. By 2 | explicitly commenting empty methods it is easier to distinguish between intentional (commented) and unintentional 3 | empty methods.

4 | 5 |

6 | This rule is deprecated, use {rule:java:S1186} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnconditionalIfStatement.html: -------------------------------------------------------------------------------- 1 | Do not use if statements that are always true or always false. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S2583} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnnecessaryCaseChange.html: -------------------------------------------------------------------------------- 1 | Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals() 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1157} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnnecessaryConstructor.html: -------------------------------------------------------------------------------- 1 | This rule detects when a constructor is not necessary; i.e., when there's only one constructor, it's public, has an empty body, and takes no arguments. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1186} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnnecessaryConversionTemporary.html: -------------------------------------------------------------------------------- 1 | Avoid unnecessary temporaries when converting primitives to Strings 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1158} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnnecessaryFinalModifier.html: -------------------------------------------------------------------------------- 1 | When a class has the final modifier, all the methods are automatically final. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnnecessaryFullyQualifiedName.html: -------------------------------------------------------------------------------- 1 | Import statements allow the use of non-fully qualified names. The use of a fully qualified name 2 | which is covered by an import statement is redundant. Consider using the non-fully qualified name. Example: 3 |
 4 | import java.util.List;
 5 | 
 6 | public class Foo {
 7 |    private java.util.List list1; // Unnecessary FQN
 8 |    private List list2; // More appropriate given import of 'java.util.List'
 9 | }
10 | 
11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnnecessaryLocalBeforeReturn.html: -------------------------------------------------------------------------------- 1 | Avoid unnecessarily creating local variables 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1488} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnnecessaryParentheses.html: -------------------------------------------------------------------------------- 1 | Sometimes expressions are wrapped in unnecessary parentheses, making them look like a function call. Example : 2 |
 3 | public class Foo {
 4 |   boolean bar() {
 5 |     return (true);
 6 |   }
 7 | }
 8 | 
9 | 10 |

11 | This rule is deprecated, use {rule:java:UselessParenthesesCheck} instead. 12 |

13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnnecessaryReturn.html: -------------------------------------------------------------------------------- 1 | Avoid unnecessary return statements 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnnecessaryWrapperObjectCreation.html: -------------------------------------------------------------------------------- 1 | Parsing method should be called directy instead. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1158} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnsynchronizedStaticDateFormatter.html: -------------------------------------------------------------------------------- 1 | SimpleDateFormat is not synchronized. Sun recomends separate format instances for each thread. If multiple threads must access a static formatter, the formatter must be synchronized either on method or block level. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S2156} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnusedFormalParameter.html: -------------------------------------------------------------------------------- 1 |

Avoid passing parameters to methods or constructors and then not using those parameters.

2 | 3 |

4 | This rule is deprecated, use {rule:java:S1172} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnusedImports.html: -------------------------------------------------------------------------------- 1 | Avoid unused import statements. Example : 2 |
 3 | // this is bad
 4 | import java.io.File;
 5 | public class Foo {}
 6 |   
7 | 8 |

9 | This rule is deprecated, use {rule:java:UselessImportCheck} instead. 10 |

11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnusedImportsWithTypeResolution.html: -------------------------------------------------------------------------------- 1 | Avoid unused import statements. This rule will find unused on demand imports, i.e. import com.foo.*. Example: 2 |
 3 | import java.io.*; // not referenced or required
 4 | 
 5 | public class Foo {}
 6 | 
7 | 8 |

9 | This rule is deprecated, use {rule:java:UselessImportCheck} instead. 10 |

11 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnusedLocalVariable.html: -------------------------------------------------------------------------------- 1 | Detects when a local variable is declared and/or assigned, but not used. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1481} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnusedModifier.html: -------------------------------------------------------------------------------- 1 | Fields in interfaces are automatically public static final, and methods are public abstract. Classes or interfaces nested in an interface are automatically public and static (all nested interfaces are automatically static). For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnusedNullCheckInEquals.html: -------------------------------------------------------------------------------- 1 | After checking an object reference for null, you should invoke equals() on that object rather than passing it to another object's equals() method. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnusedPrivateField.html: -------------------------------------------------------------------------------- 1 | Detects when a private field is declared and/or assigned a value, but not used. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1068} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UnusedPrivateMethod.html: -------------------------------------------------------------------------------- 1 |

2 | Unused Private Method detects when a private method is declared but is unused. This PMD rule should be switched off 3 | and replaced by its equivalent from Squid that is more effective : it generates less false-positives and detects more 4 | dead code. 5 |

6 | 7 |

8 | This rule is deprecated, use {rule:java:UnusedPrivateMethod} instead. 9 |

10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseArrayListInsteadOfVector.html: -------------------------------------------------------------------------------- 1 | ArrayList is a much better Collection implementation than Vector. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1149} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseArraysAsList.html: -------------------------------------------------------------------------------- 1 | The class java.util.Arrays has a asList method that should be use when you want to create a new List from an array of objects. It is faster than executing a loop to cpy all the elements of the array one by one 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseCollectionIsEmpty.html: -------------------------------------------------------------------------------- 1 | The isEmpty() method on java.util.Collection is provided to see if a collection has any elements. Comparing the value of size() to 0 merely duplicates existing behavior. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1155} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseConcurrentHashMap.html: -------------------------------------------------------------------------------- 1 | Since Java5 brought a new implementation of the Map interface, specially designed for concurrent application. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseCorrectExceptionLogging.html: -------------------------------------------------------------------------------- 1 | To make sure the full stacktrace is printed out, use the logging statement with 2 arguments: a String and a Throwable. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1166} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseEqualsToCompareStrings.html: -------------------------------------------------------------------------------- 1 | Using "==" or "!=" to compare strings only works if intern version is used on both sides. 2 | 3 |

4 | This rule is deprecated, use {rule:java:StringEqualityComparisonCheck} or {rule:java:S1698} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseIndexOfChar.html: -------------------------------------------------------------------------------- 1 | Use String.indexOf(char) when checking for the index of a single character; it executes faster. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseLocaleWithCaseConversions.html: -------------------------------------------------------------------------------- 1 | When doing a String.toLowerCase()/toUpperCase() call, use a Locale. This avoids problems with certain locales, i.e. Turkish. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseNotifyAllInsteadOfNotify.html: -------------------------------------------------------------------------------- 1 | Thread.notify() awakens a thread monitoring the object. If more than one thread is monitoring, then only one is chosen. The thread chosen is arbitrary; thus it's usually safer to call notifyAll() instead. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S2446} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseProperClassLoader.html: -------------------------------------------------------------------------------- 1 | In J2EE getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseStringBufferForStringAppends.html: -------------------------------------------------------------------------------- 1 | Finds usages of += for appending strings. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseStringBufferLength.html: -------------------------------------------------------------------------------- 1 | Use StringBuffer.length() to determine StringBuffer length rather than using StringBuffer.toString().equals() or StringBuffer.toString().length() ==. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UseUtilityClass.html: -------------------------------------------------------------------------------- 1 | For classes that only have static methods, consider making them utility classes. 2 | Note that this doesn't apply to abstract classes, since their subclasses may well include non-static methods. 3 | Also, if you want this class to be a utility class, remember to add a private constructor to prevent instantiation. 4 | (Note, that this use was known before PMD 5.1.0 as UseSingleton). 5 | 6 |

7 | This rule is deprecated, use {rule:java:S1118} instead. 8 |

9 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UselessOperationOnImmutable.html: -------------------------------------------------------------------------------- 1 | An operation on an Immutable object (BigDecimal or BigInteger) won't change the object itself. The result of the operation is a new object. Therefore, ignoring the operation result is an error. 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UselessOverridingMethod.html: -------------------------------------------------------------------------------- 1 | The overriding method merely calls the same method defined in a superclass 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1185} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UselessParentheses.html: -------------------------------------------------------------------------------- 1 | Useless parentheses should be removed. Example: 2 |
 3 | public class Foo {
 4 | 
 5 |    private int _bar1;
 6 |    private Integer _bar2;
 7 | 
 8 |    public void setBar(int n) {
 9 |       _bar1 = Integer.valueOf((n)); // here
10 |       _bar2 = (n); // and here
11 |    }
12 | 
13 | }
14 | 
15 | 16 |

17 | This rule is deprecated, use {rule:java:UselessParenthesesCheck} instead. 18 |

19 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/UselessStringValueOf.html: -------------------------------------------------------------------------------- 1 | No need to call String.valueOf to append to a string; just use the valueOf() argument directly. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S1153} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/VariableNamingConventions.html: -------------------------------------------------------------------------------- 1 | A variable naming conventions rule - customize this to your liking. Currently, it checks for final variables that should be fully capitalized and non-final variables that should not include underscores. 2 | 3 |

4 | This rule is deprecated, use {rule:java:S115} and {rule:java:S116} instead. 5 |

6 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/WhileLoopsMustUseBraces.html: -------------------------------------------------------------------------------- 1 |

2 | Avoid using 'while' statements without using curly braces. 3 |

4 | 5 |

6 | This rule is deprecated, use {rule:java:S121} instead. 7 |

8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules-kotlin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MAJOR 5 | category/kotlin/bestpractices.xml/FunctionNameTooShort 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/test/kotlin/TestKotlin.kt: -------------------------------------------------------------------------------- 1 | fun a(): Int { 1 } 2 | 3 | fun abc(): Int { 2 } -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/test/resources/org/sonar/l10n/languageKey/rules/repoKey/ruleWithExternalInfo.html: -------------------------------------------------------------------------------- 1 | description for ruleWithExternalInfo 2 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/test/resources/org/sonar/plugins/pmd/export_rule_with_all_params_empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sonar Profile: pmd 4 | 5 | 2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/test/resources/org/sonar/plugins/pmd/export_rule_with_empty_param.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/test/resources/org/sonar/plugins/pmd/export_xpath_rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sonar Profile: pmd 4 | 5 | 3 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/test/resources/org/sonar/plugins/pmd/junit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sonar PMD Unit Tests rules 4 | 5 | 6 | 7 | 9 | 10 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/test/resources/org/sonar/plugins/pmd/simple-kotlin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sonar PMD kotlin rules 4 | 5 | 2 6 | 7 | 8 | -------------------------------------------------------------------------------- /sonar-pmd-plugin/src/test/resources/org/sonar/plugins/pmd/source.txt: -------------------------------------------------------------------------------- 1 | Example source --------------------------------------------------------------------------------