### Main changes to java module and integration - [x] #2689 - [x] #3113 - Flesh out symbol API a bit. Expose: - [x] #3752 * default values for annotation methods * annotations (possibly only partially as a first step, eg meta-annotations `@Target`, `@Retention`) - [x] #4243 - [x] #2387 * record components - [x] enum constants already done - [x] #2777 - [x] #3311 - [x] #3755 - [x] #3784 will make changes to comment handling - [x] #3831 - [x] Remove `TypeNode#getType` - [x] #3906 - [x] #3839 - [x] Remove `JClassSymbol#getJvmRepr`: we don't load classes anymore - [x] Revisit module declaration grammar to get rid of ASTName #3890 ### Updating rules <details> <summary>:heavy_check_mark: this is done</summary> - [x] #2778 Replace package-global suppression by `@Ignore` annotations [(branch)](https://github.com/oowekyala/pmd/tree/use-ignore-annotations-java-grammar) Rules to port - [x] bestpractices.xml - [x] AbstractClassWithoutAbstractMethod #3116 - [x] AccessorClassGeneration #2899 - [x] AccessorMethodGeneration #2899 - [x] ArrayIsStoredDirectly #3127 - [x] AvoidMessageDigestField #2899 - [x] AvoidPrintStackTrace #2899 - [x] AvoidReassigningCatchVariables #3113 - [x] AvoidReassigningLoopVariables #3113 - [x] AvoidReassigningParameters #3113 - [x] AvoidStringBufferField #2899 - [x] AvoidUsingHardCodedIP #3116 - [x] CheckResultSet #3116 - [x] ConstantsInInterface #2899 - [x] DefaultLabelNotLastInSwitchStmt #2899 - [x] DoubleBraceInitialization #2899 - [x] ForLoopCanBeForeach #3126 - [x] ForLoopVariableCount #2899 - [x] GuardLogStatement #3116 - [x] JUnit4SuitesShouldUseSuiteAnnotation #3176 - [x] JUnit4TestShouldUseAfterAnnotation #3176 - [x] JUnit4TestShouldUseBeforeAnnotation #3176 - [x] JUnit4TestShouldUseTestAnnotation #3176 - [x] JUnitAssertionsShouldIncludeMessage #2899 - [x] JUnitTestContainsTooManyAsserts #2899 - [x] JUnitTestsShouldIncludeAssert #2899 - [x] JUnitUseExpected #2899 - [x] LiteralsFirstInComparisons #2899 - [x] LooseCoupling #3177 - [x] MethodReturnsInternalArray #3127 - [x] MissingOverride #2800 - [x] OneDeclarationPerLine #3178 - [x] PositionLiteralsFirstInCaseInsensitiveComparisons 0b6f3cb991fb1588c3d2549af838aa76e6bd1519 - [x] PositionLiteralsFirstInComparisons 0b6f3cb991fb1588c3d2549af838aa76e6bd1519 - [x] PreserveStackTrace #3179 - [x] PrimitiveWrapperInstantiation (new rule with PMD 6.37.0) #3609 - [x] ReplaceEnumerationWithIterator #3180 - [x] ReplaceHashtableWithMap #3180 - [x] ReplaceVectorWithList #3180 - [x] SimplifiableTestAssertion (new rule with PMD 6.37.0) #3717 - [x] SwitchStmtsShouldHaveDefault #2899 - [x] SystemPrintln #3116 - [x] UnusedAssignment #2794 - [x] UnusedFormalParameter #3113 - [x] ~UnusedImports~ removed by 078e903b73 - [x] UnusedLocalVariable #3113 - [x] UnusedPrivateField #3113 - [x] UnusedPrivateMethod #3113 - [x] UseStandardCharsets (new rule with PMD 6.34.0, converted with merge from master->pmd/7.0.x, 70478ce403c1c864f32e417f5109943d3497c062) - [x] ~UseAssertEqualsInsteadOfAssertTrue~ #2899 :warning: deprecated - [x] ~UseAssertNullInsteadOfAssertTrue~ #2899 :warning: deprecated - [x] ~UseAssertSameInsteadOfAssertTrue~ #2899 :warning: deprecated - [x] ~UseAssertTrueInsteadOfAssertEquals~ #2899 :warning: deprecated - [x] UseCollectionIsEmpty #2899 - [x] UseTryWithResources #3181 - [x] UseVarargs #3182 - [x] WhileLoopWithLiteralBoolean #3116 - [x] codestyle.xml - [x] AtLeastOneConstructor #2899 - [x] AvoidDollarSigns #2899 - [x] AvoidProtectedFieldInFinalClass #2899 - [x] AvoidProtectedMethodInFinalClassNotExtending #2899 - [x] AvoidUsingNativeCode #2899 - [x] BooleanGetMethodName #2899 - [x] CallSuperInConstructor #2899 - [x] ClassNamingConventions #2899 - [x] CommentDefaultAccessModifier #3188 - [x] ConfusingTernary #2899 - [x] ControlStatementBraces #2899 - [x] ~DefaultPackage #2899~ - [x] ~DontImportJavaLang~ #2899, then removed by 078e903b73 - [x] ~DuplicateImports~ removed by 078e903b73 - [x] EmptyMethodInAbstractClassShouldBeAbstract #2899 - [x] ExtendsObject #2899 - [x] FieldDeclarationsShouldBeAtStartOfClass #3229 - [x] FieldNamingConventions #2899 - [x] FinalParameterInAbstractMethod (new with PMD 6.42.0) #3738 - [x] ForLoopShouldBeWhileLoop #2899 - [x] FormalParameterNamingConventions #2899 - [x] GenericsNaming #2899 - [x] IdenticalCatchBranches #3113 - [x] LinguisticNaming #3189 - [x] LocalHomeNamingConvention #2899 - [x] LocalInterfaceSessionNamingConvention #2899 - [x] LocalVariableCouldBeFinal #3113 - [x] LocalVariableNamingConventions #2899 - [x] LongVariable #2899 - [x] MDBAndSessionBeanNamingConvention #2899 - [x] MethodArgumentCouldBeFinal #3113 - [x] MethodNamingConventions #2899 - [x] NoPackage #2899 - [x] OnlyOneReturn #3227 - [x] PackageCase #2899 - [x] PrematureDeclaration #3199 - [x] RemoteInterfaceNamingConvention #2899 - [x] RemoteSessionInterfaceNamingConvention #2899 - [x] ShortClassName #2899 - [x] ShortMethodName #2899 - [x] ShortVariable #2899 - [x] TooManyStaticImports #2899 - [x] UnnecessaryAnnotationValueElement #2899 - [x] UnnecessaryCast #3204 - [x] UnnecessaryConstructor #2899 - [x] UnnecessaryFullyQualifiedName #2897 - [x] UnnecessaryImport #3718 - [x] UnnecessaryLocalBeforeReturn #3113 - [x] UnnecessaryModifier #3194 - [x] UnnecessaryReturn #3195 - [x] UseDiamondOperator #3253 - [x] UseShortArrayInitializer #2899 - [x] UseUnderscoresInNumericLiterals #2899 - [x] UselessParentheses #2900 - [x] UselessQualifiedThis #2899 - [x] design.xml - [x] AbstractClassWithoutAnyMethod #3298 - [x] AvoidCatchingGenericException #3715 - [x] AvoidDeeplyNestedIfStmts #3737 - [x] AvoidRethrowingException #3297 - [x] AvoidThrowingNewInstanceOfSameException #3736 - [x] AvoidThrowingNullPointerException #3311 - [x] AvoidThrowingRawExceptionTypes #3735 - [x] AvoidUncheckedExceptionsInSignatures #3405 - [x] ClassWithOnlyPrivateConstructorsShouldBeFinal #3404 - [x] CollapsibleIfStatements #3397 - [x] CognitiveComplexity fb294680af - [x] CouplingBetweenObjects #3734 - [x] CyclomaticComplexity #3162 - [x] DataClass #3162 - [x] DoNotExtendJavaLangError #3309 - [x] ExceptionAsFlowControl #3310 - [x] ExcessiveClassLength #3308 - [x] ExcessiveImports #3308 - [x] ExcessiveMethodLength #3308 - [x] ExcessiveParameterList #3308 - [x] ExcessivePublicCount #3308 - [x] FinalFieldCouldBeStatic #3608 - [x] GodClass #3162 - [x] ImmutableField #3311 - [x] LawOfDemeter #3510 - [x] LogicInversion #3607 - [x] LoosePackageCoupling #3733 - [x] NPathComplexity #3162 - [x] NcssCount #3162 - [x] MutableStaticState 8f4bf19f2f2c6c4cc9474be9b751c78b468d11c3 - [x] SignatureDeclareThrowsException #3731 - [x] SimplifiedTernary #3450 - [x] ~SimplifyBooleanAssertion~ :warning: deprecated - [x] SimplifyBooleanExpressions #2899 - [x] SimplifyBooleanReturns #3113 - [x] SimplifyConditional #3449 - [x] SingularField #3311 - [x] SwitchDensity #3458 - [x] TooManyFields #3730 - [x] TooManyMethods #3730 - [x] UseObjectForClearerAPI #3728 - [x] UseUtilityClass #3457 - [x] UselessOverridingMethod #3599 - [x] documentation.xml - [x] CommentContent #2802 - [x] CommentRequired #2802 - [x] CommentSize #2802 - [x] UncommentedEmptyConstructor #2899 - [x] UncommentedEmptyMethodBody #2802 - [x] errorprone.xml - [x] AssignmentInOperand #3113 - [x] AssignmentToNonFinalStatic #3598 - [x] AvoidAccessibilityAlteration #3522 - [x] AvoidAssertAsIdentifier #2899 - [x] AvoidBranchingStatementAsLastInLoop #3592 - [x] AvoidCallingFinalize #3665 - [x] AvoidCatchingNPE #3664 - [x] AvoidCatchingThrowable #2899 - [x] AvoidDecimalLiteralsInBigDecimalConstructor #2899 - [x] AvoidDuplicateLiterals #3663 - [x] AvoidEnumAsIdentifier #2899 - [x] AvoidFieldNameMatchingMethodName #3662 - [x] AvoidFieldNameMatchingTypeName #3662 - [x] AvoidInstanceofChecksInCatchClause #3591 - [x] AvoidLiteralsInIfCondition #3661 - [x] AvoidLosingExceptionInformation #3660 - [x] AvoidMultipleUnaryOperators #2899 - [x] AvoidUsingOctalValues #3398 - [x] ~BadComparison~ (deprecated since 6.36.0) - [x] BeanMembersShouldSerialize #3659 - [x] BrokenNullCheck #3191 - [x] CallSuperFirst #3658 - [x] CallSuperLast #3658 - [x] CheckSkipResult #3511 - [x] ClassCastExceptionWithToArray #3556 - [x] CloneMethodMustBePublic #3553 - [x] CloneMethodMustImplementCloneable #2899 - [x] CloneMethodReturnTypeMustMatchClassName #3552 - [x] CloneThrowsCloneNotSupportedException - :warning: rule is deprecated since 6.35.0, see #3112 - [x] CloseResource #3550 - [x] CompareObjectsWithEquals #2899 - [x] ComparisonWithNaN #3396 - [x] ConstructorCallsOverridableMethod #3358 - [x] ~DataflowAnomalyAnalysis~ - [x] DetachedTestCase #3655 - [x] DoNotCallGarbageCollectionExplicitly #3548 - [x] ~DoNotCallSystemExit~ removed - [x] DoNotExtendJavaLangThrowable #3654 - [x] DoNotHardCodeSDCard #3653 - [x] DoNotTerminateVM #3739 - [x] DoNotThrowExceptionInFinally #3652 - [x] DontImportSun #3391 - [x] DontUseFloatTypeForLoopIndices #3547 - [x] EmptyCatchBlock #2899 - [x] EmptyFinalizer #2899 - [x] EmptyFinallyBlock #2899 - [x] EmptyIfStmt #2899 - [x] EmptyInitializer #2899 - [x] EmptyStatementBlock #2899 - [x] EmptyStatementNotInLoop #2899 - [x] EmptySwitchStatements #2899 - [x] EmptySynchronizedBlock #2899 - [x] EmptyTryBlock #2899 - [x] EmptyWhileStmt #2899 - [x] EqualsNull #2899 - [x] FinalizeDoesNotCallSuperFinalize #3384 - [x] FinalizeOnlyCallsSuperFinalize #3384 - [x] FinalizeOverloaded #3384 - [x] FinalizeShouldBeProtected #3384 - [x] IdempotentOperations #3390 - [x] ImplicitSwitchFallThrough - [x] ~ImportFromSamePackage~ removed by 078e903b73 - [x] InstantiationToGetClass #3384 - [x] InvalidLogMessageFormat #3512 - [x] JUnitSpelling #2899 - [x] JUnitStaticSuite #2899 - [x] JumbledIncrementer #3546 - [x] MethodWithSameNameAsEnclosingClass #3651 - [x] MisplacedNullCheck #3545 - [x] MissingBreakInSwitch #3311 - :warning: Renamed to ImplicitSwitchFallThrough see #3361 - [x] MissingSerialVersionUID #3384 - [x] MissingStaticMethodInNonInstantiatableClass #3537 - [x] MoreThanOneLogger #3650 - [x] NonCaseLabelInSwitchStatement #3536 - [x] NonStaticInitializer #3384 - [x] NullAssignment #3649 - [x] OverrideBothEqualsAndHashcode #3535 - [x] ProperCloneImplementation #3534 - [x] ProperLogger #3611 - [x] ReturnEmptyArrayRatherThanNull :warning: is deprecated, see #3382 - [x] ReturnEmptyCollectionRatherThanNull (new rule with PMD 6.37.0) #3533 - [x] ReturnFromFinallyBlock #3381 - [x] SimpleDateFormatNeedsLocale #3610 - [x] SingleMethodSingleton #3531 - [x] SingletonClassReturningNewInstance #3530 - [x] StaticEJBFieldShouldBeFinal #3529 - [x] StringBufferInstantiationWithChar #3528 - [x] SuspiciousEqualsMethodName #3389 - [x] SuspiciousHashcodeMethodName #3389 - [x] SuspiciousOctalEscape #3527 - [x] TestClassWithoutTestCases #2899 - [x] UnconditionalIfStatement #3526 - [x] UnnecessaryBooleanAssertion #3525 - [x] UnnecessaryCaseChange #3524 - [x] UnnecessaryConversionTemporary #3523 - [x] UnusedNullCheckInEquals #3485 - [x] UseCorrectExceptionLogging #3483 - [x] UseEqualsToCompareStrings #3479 - [x] UseLocaleWithCaseConversions #3478 - [x] UseProperClassLoader #3477 - [x] UselessOperationOnImmutable #2899 - [x] multithreading.xml - [x] AvoidSynchronizedAtMethodLevel #2899 - [x] AvoidThreadGroup #2899 - [x] AvoidUsingVolatile #2899 - [x] DoNotUseThreads #2899 - [x] DontCallThreadRun #2899 - [x] DoubleCheckedLocking #2899 - [x] NonThreadSafeSingleton #3474 - [x] UnsynchronizedStaticFormatter #3472 - [x] UseConcurrentHashMap #2899 - [x] UseNotifyAllInsteadOfNotify #2899 - [x] performance.xml - [x] AddEmptyString #2899 - [x] AppendCharacterWithChar #2899 - [x] AvoidArrayLoops #3408 - [x] AvoidCalendarDateCreation #3395 - [x] AvoidFileStream #2899 - [x] AvoidInstantiatingObjectsInLoops #3394 - [x] ~AvoidUsingShortType #2899~ :warning: deprecated - [x] BigIntegerInstantiation #3386 - [x] ~BooleanInstantiation~ :warning: deprecated - [x] ~ByteInstantiation #2899~ -> :warning: New rule: PrimitiveWrapperConstructor #3365 :warning: deprecated - [x] ConsecutiveAppendsShouldReuse #3113 - [x] ConsecutiveLiteralAppends #3335 - [x] InefficientEmptyStringCheck #2899 - [x] InefficientStringBuffering #3113 - [x] InsufficientStringBufferDeclaration #3278 - [x] ~IntegerInstantiation #2899~ -> :warning: New rule: PrimitiveWrapperConstructor #3365 :warning: deprecated - [x] ~LongInstantiation #2899~ -> :warning: New rule: PrimitiveWrapperConstructor #3365 :warning: deprecated - [x] OptimizableToArrayCall #3271 - [x] RedundantFieldInitializer #2899 - [x] ~ShortInstantiation #2899~ -> :warning: New rule: PrimitiveWrapperConstructor #3365 :warning: deprecated - [x] ~SimplifyStartsWith #2899~ :warning: deprecated - [x] StringInstantiation #2899 - [x] StringToString #2689 - [x] TooFewBranchesForASwitchStatement #2899 - [x] ~UnnecessaryWrapperObjectCreation #3418~ :warning: deprecated The replacement is the new rule UnnecessaryBoxing (#3364) - [x] UseArrayListInsteadOfVector #2899 - [x] UseArraysAsList #3187 - [x] UseIOStreamsWithApacheCommonsFileItem #3172 - [x] UseIndexOfChar #2899 - [x] UseStringBufferForStringAppends #3171 - [x] UseStringBufferLength #2899 - [x] UselessStringValueOf #2899 - [x] security.xml - [x] HardCodedCryptoKey #3086 - [x] InsecureCryptoIv #3086 </details> ## Remaining tasks ### Probably for PMD 7 * #4317 * #4319 * #3751 ### Postponed * #4318 * #4316
Main changes to java module and integration
[java] New type resolution #2689
[java] Usage resolution for java variables #3113
Flesh out symbol API a bit. Expose:
@Target,@Retention)[java] Implement constant values #2777
[java] Extract reaching definitions analysis out of UnusedAssignmentRule #3311
[java] Implement pattern binding scoping #3755
[core] Text documents epic #3784 will make changes to comment handling
[java] Cleanup java module #3831
TypeNode#getTypeRemove
JClassSymbol#getJvmRepr: we don't load classes anymoreRevisit module declaration grammar to get rid of ASTName [java] Improve module grammar #3890
Updating rules
✔️ this is done
@Ignoreannotations (branch)Rules to port
bestpractices.xml
UnusedImportsremoved by 078e903UseAssertEqualsInsteadOfAssertTrue[java] Update many java rules #2899UseAssertNullInsteadOfAssertTrue[java] Update many java rules #2899UseAssertSameInsteadOfAssertTrue[java] Update many java rules #2899UseAssertTrueInsteadOfAssertEquals[java] Update many java rules #2899codestyle.xml
DefaultPackage [java] Update many java rules #2899DontImportJavaLang[java] Update many java rules #2899, then removed by 078e903DuplicateImportsremoved by 078e903design.xml
SimplifyBooleanAssertiondocumentation.xml
errorprone.xml
BadComparison(deprecated since 6.36.0)DataflowAnomalyAnalysisDoNotCallSystemExitremovedImportFromSamePackageremoved by 078e903multithreading.xml
performance.xml
AvoidUsingShortType [java] Update many java rules #2899BooleanInstantiationByteInstantiation [java] Update many java rules #2899->IntegerInstantiation [java] Update many java rules #2899->LongInstantiation [java] Update many java rules #2899->ShortInstantiation [java] Update many java rules #2899->SimplifyStartsWith [java] Update many java rules #2899UnnecessaryWrapperObjectCreation [java] Update rule UnnecessaryWrapperObjectCreation #3418security.xml
Remaining tasks
Probably for PMD 7
Postponed
Node::getImage#4318