Table of Contents
25-October-2024 - 7.7.0
The PMD team is pleased to announce PMD 7.7.0.
This is a minor release.
🚀 New and noteworthy
CPD can now ignore literals and identifiers in C++ code
When searching for duplicated code in C++ differences in literals or identifiers can be
ignored now (like in Java). This can be enabled via the command line options --ignore-literal
and --ignore-identifiers
.
See PR #5040 for details.
🌟 Rule Changes
Changed Rules
SwitchStmtsShouldHaveDefault
(Java Best Practices) doesn’t report empty switch statements anymore. To detect these, useEmptyControlStatement
.UnitTestShouldUseAfterAnnotation
(Java Best Practices) now also considers JUnit 5 and TestNG tests.UnitTestShouldUseBeforeAnnotation
(Java Best Practices) now also considers JUnit 5 and TestNG tests.TooFewBranchesForSwitch
(Java Performance) doesn’t report empty switches anymore. To detect these, useEmptyControlStatement
.
Renamed Rules
- Several rules for unit testing have been renamed to better reflect their actual scope. Lots of them were called
after JUnit / JUnit 4, even when they applied to JUnit 5 and / or TestNG.
UnitTestAssertionsShouldIncludeMessage
(Java Best Practices) has been renamed fromJUnitAssertionsShouldIncludeMessage
.UnitTestContainsTooManyAsserts
(Java Best Practices) has been renamed fromJUnitTestContainsTooManyAsserts
.UnitTestShouldIncludeAssert
(Java Best Practices) has been renamed fromJUnitTestsShouldIncludeAssert
.UnitTestShouldUseAfterAnnotation
(Java Best Practices) has been renamed fromJUnit4TestShouldUseAfterAnnotation
.UnitTestShouldUseBeforeAnnotation
(Java Best Practices) has been renamed fromJUnit4TestShouldUseBeforeAnnotation
.UnitTestShouldUseTestAnnotation
(Java Best Practices) has been renamed fromJUnit4TestShouldUseTestAnnotation
.
- Several rules about switch statements and switch expression have been renamed, as they apply both to Switch Statements
and to Switch Expressions:
DefaultLabelNotLastInSwitch
(Java Best Practices) has been renamed fromDefaultLabelNotLastInSwitch
.NonCaseLabelInSwitch
(Java Error Prone) has been renamed fromNonCaseLabelInSwitchStatement
.TooFewBranchesForSwitch
(Java Performance) has been renamed fromTooFewBranchesForASwitchStatement
.NonExhaustiveSwitch
(Java Best Practices) has been renamed fromSwitchStmtsShouldHaveDefault
.
The old rule names still work but are deprecated.
🐛 Fixed Issues
- apex-performance
- #5270: [apex] AvoidNonRestrictiveQueries when LIMIT is followed by bind expression
- java
- java-bestpractices
- java-codestyle
- #5253: [java] BooleanGetMethodName: False-negatives with
Boolean
wrapper
- #5253: [java] BooleanGetMethodName: False-negatives with
- java-design
- #5030: [java] SwitchDensity false positive with pattern matching
- java-errorprone
- java-performance
🚨 API Changes
- java-bestpractices
- The old rule name
JUnit4TestShouldUseAfterAnnotation
has been deprecated. Use the new nameUnitTestShouldUseAfterAnnotation
instead. - The old rule name
JUnit4TestShouldUseBeforeAnnotation
has been deprecated. Use the new nameUnitTestShouldUseBeforeAnnotation
instead. - The old rule name
JUnit4TestShouldUseTestAnnotation
has been deprecated. Use the new nameUnitTestShouldUseTestAnnotation
instead. - The old rule name
JUnitAssertionsShouldIncludeMessage
has been deprecated. Use the new nameUnitTestAssertionsShouldIncludeMessage
instead. - The old rule name
JUnitTestContainsTooManyAsserts
has been deprecated. Use the new nameUnitTestContainsTooManyAsserts
instead. - The old rule name
JUnitTestsShouldIncludeAssert
has been deprecated. Use the new nameUnitTestShouldIncludeAssert
instead. - The old rule name
DefaultLabelNotLastInSwitch
has been deprecated. Use the new nameDefaultLabelNotLastInSwitch
instead. - The old rule name
SwitchStmtsShouldHaveDefault
has been deprecated. USe the new nameNonExhaustiveSwitch
instead.
- The old rule name
- java-errorprone
- The old rule name
NonCaseLabelInSwitchStatement
has been deprecated. Use the new nameNonCaseLabelInSwitch
instead.
- The old rule name
- java-performance
- The old rule name
TooFewBranchesForASwitchStatement
has been deprecated. Use the new nameTooFewBranchesForSwitch
instead.
- The old rule name
✨ Merged pull requests
- #4965: Fix #4532: [java] Rename JUnit rules with overly restrictive names - Juan Martín Sotuyo Dodero (@jsotuyod)
- #5040: [cpp] Ignore literals and ignore identifiers capability to C++ CPD - Jakub Dupak (@jdupak)
- #5225: Fix #5067: [java] CloseResource: False positive for FileSystems.getDefault() - Lukas Gräf (@lukasgraef)
- #5241: Ignore javacc code in coverage report - Juan Martín Sotuyo Dodero (@jsotuyod)
- #5245: [java] Improve UnitTestShouldUse{After,Before}Annotation rules to support JUnit5 and TestNG - Andreas Dangel (@adangel)
- #5247: Fix #5030: [java] SwitchDensity false positive with pattern matching - Andreas Dangel (@adangel)
- #5248: Fix #3362: [java] ImplicitSwitchFallThrough should consider switch expressions - Andreas Dangel (@adangel)
- #5251: Fix #5249 and #5250: [java] TooFewBranchesForSwitch ignore pattern matching and support switch expressions - Andreas Dangel (@adangel)
- #5252: Fix #4813: [java] SwitchStmtsShouldHaveDefault false positive with pattern matching - Andreas Dangel (@adangel)
- #5255: [java] Rename rule DefaultLabelNotLastInSwitch - Andreas Dangel (@adangel)
- #5256: Fix #5257: [java] NonCaseLabelInSwitch - support switch expressions - Andreas Dangel (@adangel)
- #5258: Ignore generated antlr classes in coverage reports - Juan Martín Sotuyo Dodero (@jsotuyod)
- #5264: Fix #5261: [java] Fix NPE with empty pattern list - Clément Fournier (@oowekyala)
- #5267: [java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch - Andreas Dangel (@adangel)
- #5269: Fix #5253: [java] Support Boolean wrapper class for BooleanGetMethodName rule - Aryant Tripathi (@Aryant-Tripathi)
- #5273: Fix #5270: [apex] AvoidNonRestrictiveQueries: Fix regex for detecting LIMIT clause - Andreas Dangel (@adangel)
- #5275: Use plugin-classpath to simplify javacc-wrapper.xml - Andreas Dangel (@adangel)
- #5278: [java] CouplingBetweenObjects: improve violation message - Andreas Dangel (@adangel)
- #5279: Fix #5244: [java] UselessOperationOnImmutable: consider java.time.* types - Andreas Dangel (@adangel)
📦 Dependency updates
- #5234: Bump com.google.protobuf:protobuf-java from 3.25.3 to 4.28.2
- #5274: Bump org.junit from 5.8.2 to 5.11.2
- #5276: Bump org.checkerframework:checker-qual from 2.11.1 to 3.48.1
- #5280: Bump danger from 9.5.0 to 9.5.1 in the all-gems group across 1 directory
- #5281: Bump org.scala-lang:scala-reflect from 2.13.13 to 2.13.15
📈 Stats
- 98 commits
- 32 closed tickets & PRs
- Days since last release: 27