Releases: pmd/pmd
PMD 7.0.0-rc1 (25-March-2023)
25-March-2023 - 7.0.0-rc1
We're excited to bring you the next major version of PMD!
Since this is a big release, we provide here only a concise version of the release notes. We prepared a separate
page with the full Detailed Release Notes for PMD 7.0.0.
PMD 7.0.0 is finally almost ready. In order to gather feedback, we are going to ship a couple of release candidates. These are officially available on GitHub and Maven Central and can be used as usual (e.g. as a dependency). We encourage you to try out the new features, but keep in mind that we may introduce API breaking changes between the release candidates. It should be stable enough if you don't use custom rules.
We have still some tasks planned for the next release candidates. You can see the progress in PMD 7 Tracking Issue #3898.
If you find any problem or difficulty while updating from PMD 6, please provide feedback via our issue tracker. That way we can improve the experience for all.
Expand to see Release Notes
Table Of Contents
- 🚀 Major Features and Enhancements
- 🎉 Language Related Changes
- New: Swift support
- New: Kotlin support (experimental)
- Changed: JavaScript support
- Changed: Language versions
- 🌟 New and changed rules
- 🚨 API
- 💥 Compatibility and migration notes
- 🐛 Fixed Issues
- ✨ External Contributions
- 📈 Stats
🚀 Major Features and Enhancements
New official logo
The new official logo of PMD:
Revamped Java module
- Java grammar substantially refactored - more correct regarding the Java Language Specification (JLS)
- Built-in rules have been upgraded for the changed AST
- Rewritten type resolution framework and symbol table correctly implements the JLS
- AST exposes more semantic information (method calls, field accesses)
For more information, see the Detailed Release Notes for PMD 7.
Contributors: Clément Fournier (@oowekyala),
Andreas Dangel (@adangel),
Juan Martín Sotuyo Dodero (@jsotuyod)
Revamped Command Line Interface
- unified and consistent Command Line Interface for both Linux/Unix and Windows across our different utilities
- single script
pmd
(pmd.bat
for Windows) to launch the different utilities:pmd check
to run PMD rules and analyze a projectpmd cpd
to run CPD (copy paste detector)pmd designer
to run the PMD Rule Designer
- progress bar support for
pmd check
- shell completion
For more information, see the Detailed Release Notes for PMD 7.
Contributors: Juan Martín Sotuyo Dodero (@jsotuyod)
Full Antlr support
- Antlr based grammars can now be used to build full-fledged PMD rules.
- Previously, Antlr grammar could only be used for CPD
- New supported languages: Swift and Kotlin
For more information, see the Detailed Release Notes for PMD 7.
Contributors: Lucas Soncini (@lsoncini),
Matías Fraga (@matifraga),
Tomás De Lucca (@tomidelucca)
🎉 Language Related Changes
Note that this is just a concise listing of the highlight.
For more information on the languages, see the Detailed Release Notes for PMD 7.
New: Swift support
- use PMD to analyze Swift code with PMD rules
- initially 4 built-in rules
Contributors: Lucas Soncini (@lsoncini),
Matías Fraga (@matifraga),
Tomás De Lucca (@tomidelucca)
New: Kotlin support (experimental)
- use PMD to analyze Kotlin code with PMD rules
- Support for Kotlin 1.8 grammar
- initially 2 built-in rules
Changed: JavaScript support
- latest version supports ES6 and also some new constructs (see Rhino])
- comments are retained
Changed: Language versions
- more predefined language versions for each supported language
- can be used to limit rule execution for specific versions only with
minimumLanguageVersion
and
maximumLanguageVersion
attributes.
🌟 New and changed rules
New Rules
Apex
UnusedMethod
finds unused methods in your code.
Java
UnnecessaryBoxing
reports boxing and unboxing conversions that may be made implicit.
Kotlin
Swift
Changed Rules
Java
UnnecessaryFullyQualifiedName
: the rule has two new properties,
to selectively disable reporting on static field and method qualifiers. The rule also has been improved
to be more precise.UselessParentheses
: the rule has two new properties which control how strict
the rule should be applied. WithignoreClarifying
(default: true) parentheses that are strictly speaking
not necessary are allowed, if they separate expressions of different precedence.
The other propertyignoreBalancing
(default: true) is similar, in that it allows parentheses that help
reading and understanding the expressions.LooseCoupling
: the rule has a new property to allow some types to be coupled
to (allowedTypes
).EmptyCatchBlock
:CloneNotSupportedException
andInterruptedException
are not
special-cased anymore. Rename the exception parameter toignored
to ignore them.DontImportSun
:sun.misc.Signal
is not special-cased anymore.UseDiamondOperator
: the propertyjava7Compatibility
is removed. The rule now
handles Java 7 properly without a property.SingularField
: PropertiescheckInnerClasses
anddisallowNotAssignment
are removed.
The rule is now more precise and will check these cases properly.UseUtilityClass
: The propertyignoredAnnotations
has been removed.LawOfDemeter
: the rule has a new propertytrustRadius
. This defines the maximum degree
of trusted data. The default of 1 is the most restrictive.CommentContent
: The propertiescaseSensitive
anddisallowedTerms
are removed. The
new propertyfobiddenRegex
can be used now to define the disallowed terms with a single regular
expression.
Removed Rules
Many rules, that were previously deprecated have been finally removed.
See Detailed Release Notes for PMD 7 for the complete list.
🚨 API
The API of PMD has been growing over the years and needed some cleanup. The goal is, to
have a clear separation between a well-defined API and the implementation, which is internal.
This should help us in future development.
Also, there are some improvement and changes in different areas. For the ...
PMD 6.55.0 (25-February-2023)
25-February-2023 - 6.55.0
The PMD team is pleased to announce PMD 6.55.0.
This is a minor release.
Table Of Contents
New and noteworthy
PMD 7 Development
This release is the last planned release of PMD 6. The first version 6.0.0 was released in December 2017.
Over the course of more than 5 years we published almost every month a new minor version of PMD 6
with new features and improvements.
Already in November 2018 we started in parallel the development of the next major version 7.0.0,
and we are now in the process of finalizing the scope of the major version. We want to release a couple of
release candidates before publishing the final version 7.0.0.
We plan to release 7.0.0-rc1 soon. You can see the progress in PMD 7 Tracking Issue #3898.
Java 20 Support
This release of PMD brings support for Java 20. There are no new standard language features.
PMD supports JEP 433: Pattern Matching for switch (Fourth Preview) and
JEP 432: Record Patterns (Second Preview) as preview language features.
In order to analyze a project with PMD that uses these language features,
you'll need to enable it via the environment variable PMD_JAVA_OPTS
and select the new language
version 20-preview
:
export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd --use-version java-20-preview ...
T-SQL support
Thanks to the contribution from Paul Guyot PMD now has CPD support
for T-SQL (Transact-SQL).
Being based on a proper Antlr grammar, CPD can:
- ignore comments
- honor comment-based suppressions
Fixed Issues
- core
- #4395: [core] Support environment variable CLASSPATH with pmd.bat under Windows
- java
- #4333: [java] Support JDK 20
- java-errorprone
- #4393: [java] MissingStaticMethodInNonInstantiatableClass false-positive for Lombok's @UtilityClass for classes with non-private fields
API Changes
Go
- The LanguageModule of Go, that only supports CPD execution, has been deprecated. This language
is not fully supported by PMD, so having a language module does not make sense. The functionality of CPD is
not affected by this change. The following class has been deprecated and will be removed with PMD 7.0.0:
Java
- Support for Java 18 preview language features have been removed. The version "18-preview" is no longer available.
- The experimental class
net.sourceforge.pmd.lang.java.ast.ASTGuardedPattern
has been removed.
External Contributions
- #4384: [swift] Add more swift 5.x support (#unavailable mainly) - Richard B. (@kenji21)
- #4390: Add support for T-SQL using Antlr4 lexer - Paul Guyot (@pguyot)
- #4392: [java] Fix #4393 MissingStaticMethodInNonInstantiatableClass: Fix false-positive for field-only class - Dawid Ciok (@dawiddc)
Stats
- 40 commits
- 11 closed tickets & PRs
- Days since last release: 28
PMD 6.54.0 (28-January-2023)
28-January-2023 - 6.54.0
The PMD team is pleased to announce PMD 6.54.0.
This is a minor release.
Table Of Contents
New and noteworthy
New report format html-report-v2.xslt
Thanks to @mohan-chinnappan-n a new PMD report format has been added which features a data table
with charting functions. It uses an XSLT stylesheet to convert PMD's XML format into HTML.
See the example report.
Fixed Issues
- apex-bestpractices
- #2669: [apex] UnusedLocalVariable false positive in dynamic SOQL
- core
- java
- #4364: [java] Parsing error with textblock containing quote followed by two backslashes
- testing
- #4236: [test] kotest logs look broken
API Changes
PMD CLI
- PMD now supports a new
--relativize-paths-with
flag (or short-z
), which replaces--short-names
.
It serves the same purpose: Shortening the pathnames in the reports. However, with the new flag it's possible
to explicitly define one or more pathnames that should be used as the base when creating relative paths.
The old flag--short-names
is deprecated.
Deprecated APIs
For removal
-
ApexRootNode#getApexVersion
has been deprecated for removal. The version returned is
alwaysVersion.CURRENT
, as the apex compiler integration doesn't use additional information which Apex version
actually is used. Therefore, this method can't be used to determine the Apex version of the project
that is being analyzed. -
CPDConfiguration#setEncoding
and
CPDConfiguration#getEncoding
. Use the methods
getSourceEncoding
and
setSourceEncoding
instead. Both are available
forCPDConfiguration
which extendsAbstractConfiguration
. -
BaseCLITest
andBaseCPDCLITest
have been deprecated for removal without
replacement. CLI tests should be done in pmd-core only (and in PMD7 in pmd-cli). Individual language modules
shouldn't need to test the CLI integration logic again. Instead, the individual language modules should test their
functionality as unit tests. -
FileCollector#addZipFile
has been deprecated. It is replaced
byFileCollector#addZipFileWithContent
which directly adds the
content of the zip file for analysis. -
PMDConfiguration#setReportShortNames
and
PMDConfiguration#isReportShortNames
have been deprecated for removal.
UsePMDConfiguration#addRelativizeRoot
instead.
Internal APIs
CSVWriter
- Some fields in
AbstractAntTestHelper
Experimental APIs
- CPDReport has a new method which limited mutation of a given report:
filterMatches
creates a new CPD report
with some matches removed with a given predicate based filter.
External Contributions
- #4110: [apex] Feature/unused variable bind false positive with dynamic SOQL - Thomas Prouvot (@tprouvot)
- #4125: [core] New report format html-report-v2.xslt to provide html with datatable and chart features - Mohan Chinnappan - (@mohan-chinnappan-n)
- #4280: [apex] Deprecate ApexRootNode.getApexVersion - Aaron Hurst (@aaronhurst-google)
- #4285: [java] CommentDefaultAccessModifier - add co.elastic.clients.util.VisibleForTesting as default suppressed annotation - Matthew Luckam (@mluckam)
Stats
- 107 commits
- 19 closed tickets & PRs
- Days since last release: 27
PMD 6.53.0 (31-December-2022)
31-December-2022 - 6.53.0
The PMD team is pleased to announce PMD 6.53.0.
This is a minor release.
Table Of Contents
New and noteworthy
Modified rules
- The Java rule
UnusedPrivateField
has a new propertyreportForAnnotations
.
This is a list of fully qualified names of the annotation types that should be reported anyway. If an unused field
has any of these annotations, then it is reported. If it has any other annotation, then it is still considered
to be used and is not reported.
Deprecated rules
-
The Java rules
ExcessiveClassLength
andExcessiveMethodLength
have been deprecated. The ruleNcssCount
can be used instead.
The deprecated rules will be removed with PMD 7.0.0. -
The Java rule
EmptyStatementNotInLoop
is deprecated.
Use the ruleUnnecessarySemicolon
instead.
Note: Actually it was announced to be deprecated since 6.46.0 but the rule was not marked as deprecated yet.
This has been done now.
Fixed Issues
- core
- #4248: [core] Can't analyze sources in zip files
- apex-security
- #4146: [apex] ApexCRUDViolation: Recognize User Mode in SOQL + DML
- java
- #4266: [java] PMD fails to process a record with lambda in compact constructor
- java-bestpractices
- java-design
- #2127: [java] Deprecate rules ExcessiveClassLength and ExcessiveMethodLength
- java-errorprone
- #4164: [java][doc] AvoidAssertAsIdentifier and AvoidEnumAsIdentifier - clarify use case
- java-multithreading
- #4210: [java] DoNotUseThreads report duplicate warnings
API Changes
Deprecated APIs
For removal
These classes / APIs have been deprecated and will be removed with PMD 7.0.0.
ExcessiveLengthRule
(Java)
External Contributions
- #4244: [apex] ApexCRUDViolation: user mode and system mode with test cases added - Tarush Singh (@Tarush-Singh35)
- #4274: [java] Fix finding lambda scope in record compact constructor - kdebski85 (@kdebski85)
Stats
- 43 commits
- 17 closed tickets & PRs
- Days since last release: 35
PMD 6.52.0 (26-November-2022)
26-November-2022 - 6.52.0
The PMD team is pleased to announce PMD 6.52.0.
This is a minor release.
Table Of Contents
New and noteworthy
New rules
- The new Java rule
InvalidJavaBean
identifies beans, that don't follow the JavaBeans API specification,
like beans with missing getters or setters.
<rule ref="category/java/design.xml/InvalidJavaBean"/>
Renamed rules
-
The Java rule
BeanMembersShouldSerialize
has been renamed to
NonSerializableClass
. It has been revamped to only check for classes that are marked with
Serializable
and reports each field in it, that is not serializable.The property
prefix
has been deprecated, since in a serializable class all fields have to be
serializable regardless of the name.
Modified rules
-
The rule
ClassNamingConventions
has a new propertytestClassPattern
, which is applied
to test classes. By default, test classes should end with the suffix "Test". Test classes are top-level classes, that
either inherit from JUnit 3 TestCase or have at least one method annotated with the Test annotations from
JUnit4/5 or TestNG. -
The property
ignoredAnnotations
of ruleImmutableField
has been deprecated and doesn't
have any effect anymore.
Since PMD 6.47.0, the rule only considers fields, that are initialized once and never changed. If the field is just
declared but never explicitly initialized, it won't be reported. That's the typical case when a framework sets
the field value by reflection. Therefore, the property is not needed anymore. If there is a special case where
this rule misidentifies fields as immutable, then the rule should be suppressed for these fields explicitly.
Fixed Issues
- cli
- #4215: NullPointerException when trying to open designer
- doc
- #4207: [doc] List all languages in rule doc
- java
- java-codestyle
- java-design
- #4175: [java] ImmutableField - deprecate property
ignoredAnnotations
- #4177: [java] New Rule InvalidJavaBean
- #4188: [java] ClassWithOnlyPrivateConstructorsShouldBeFinal false positive with Lombok's @NoArgsConstructor
- #4189: [java] AbstractClassWithoutAnyMethod should consider lombok's @AllArgsConstructor
- #4200: [java] ClassWithOnlyPrivateConstructorsShouldBeFinal should consider lombok's @Value
- #4175: [java] ImmutableField - deprecate property
- java-errorprone
- #1668: [java] BeanMembersShouldSerialize is extremely noisy
- #4172: [java] InvalidLogMessageFormat false positive on externally formatted strings
- #4174: [java] MissingStaticMethodInNonInstantiatableClass does not consider nested builder class
- #4176: [java] Rename BeanMembersShouldSerialize to NonSerializableClass
- #4185: [java] InvalidLogMessageFormat rule produces a NPE
- #4224: [java] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @UtilityClass
- #4225: [java] MissingStaticMethodInNonInstantiatableClass should consider Lombok's @NoArgsConstructor
- java-performance
- #4183: [java] AvoidArrayLoops regression: from false negative to false positive with final variables
API Changes
PMD CLI
-
PMD now supports a new
--use-version
flag, which receives a language-version pair (such asjava-8
orapex-54
).
This supersedes the usage of-language
/-l
and-version
/-v
, allowing for multiple versions to be set in a single run.
PMD 7 will completely remove support for-language
and-version
in favor of this new flag. -
Support for
-V
is being deprecated in favor of--verbose
in preparation for PMD 7.
In PMD 7,-v
will enable verbose mode and-V
will show the PMD version for consistency with most Unix/Linux tools. -
Support for
-min
is being deprecated in favor of--minimum-priority
for consistency with most Unix/Linux tools, where-min
would be equivalent to-m -i -n
.
CPD CLI
- CPD now supports using
-d
or--dir
as an alias to--files
, in favor of consistency with PMD.
PMD 7 will remove support for--files
in favor of these new flags.
Linux run.sh parameters
-
Using
run.sh cpdgui
will now warn about it being deprecated. Userun.sh cpd-gui
instead. -
The old designer (
run.sh designerold
) is completely deprecated and will be removed in PMD 7. Switch to the new JavaFX designer:run.sh designer
. -
The old visual AST viewer (
run.sh bgastviewer
) is completely deprecated and will be removed in PMD 7. Switch to the new JavaFX designer:run.sh designer
for a visual tool, or userun.sh ast-dump
for a text-based alternative.
Deprecated API
- The following core APIs have been marked as deprecated for removal in PMD 7:
PMD
andPMD.StatusCode
- PMD 7 will ship with a revamped CLI split from pmd-core. To programmatically launch analysis you can usePmdAnalysis
.PMDConfiguration#getAllInputPaths
- It is now superseded byPMDConfiguration#getInputPathList
PMDConfiguration#setInputPaths
- It is now superseded byPMDConfiguration#setInputPathList
PMDConfiguration#addInputPath
- It is now superseded byPMDConfiguration#addInputPath
PMDConfiguration#getInputFilePath
- It is now superseded byPMDConfiguration#getInputFile
PMDConfiguration#getIgnoreFilePath
- It is now superseded byPMDConfiguration#getIgnoreFile
PMDConfiguration#setInputFilePath
- It is now superseded byPMDConfiguration#setInputFilePath
PMDConfiguration#setIgnoreFilePath
- It is now superseded byPMDConfiguration#setIgnoreFilePath
- <a href="https://docs.pmd-code.org/...
PMD 6.51.0 (29-October-2022)
29-October-2022 - 6.51.0
The PMD team is pleased to announce PMD 6.51.0.
This is a minor release.
Table Of Contents
New and noteworthy
New Rules
- The new Apex rule
ApexUnitTestClassShouldHaveRunAs
ensures that unit tests
use System.runAs()
at least once. This makes the tests more robust, and independent from the user running it.
<rule ref="category/apex/bestpractices.xml/ApexUnitTestClassShouldHaveRunAs"/>
The rule is part of the quickstart.xml ruleset.
Modified Rules
- The Java rule
TestClassWithoutTestCases
has a new propertytestClassPattern
. This is
used to detect empty test classes by name. Previously this rule could only detect empty JUnit3 test cases
properly. To switch back to the old behavior, this property can be set to an empty value which disables the
test class detection by pattern.
Fixed Issues
- apex
- #4149: [apex] New rule: ApexUnitTestClassShouldHaveRunAs
- doc
- java-bestpractices
- #4140: [java] [doc] AccessorClassGeneration violations hidden with Java 11
- java-codestyle
- #4139: [java] UnnecessaryFullyQualifiedName FP when the same simple class name exists in the current package
- java-documentation
- #4141: [java] UncommentedEmptyConstructor FP when constructor annotated with @Autowired
- java-performance
- #1167: [java] AvoidArrayLoops false positive on double assignment
- #2080: [java] StringToString rule false-positive with field access
- #2692: [java] [doc] AvoidArrayLoops flags copy assignment in same array as sub-optimal
- #3437: [java] StringToString doesn't trigger on Bar.class.getSimpleName().toString()
- #3681: [java] StringToString doesn't trigger on string literals
- #3847: [java] AvoidArrayLoops should consider final variables
- #3977: [java] StringToString false-positive with local method name confusion
- #4091: [java] AvoidArrayLoops false negative with do-while loops
- #4148: [java] UseArrayListInsteadOfVector ignores Vector when other classes are imported
- java-errorprone
- javascript
- #4165: [javascript] InaccurateNumericLiteral underscore separator notation false positive
API Changes
No changes.
External Contributions
- #4142: [java] fix #4141 Update UncommentedEmptyConstructor - ignore @Autowired annotations - Lynn (@LynnBroe)
- #4147: [java] Added support for Do-While for AvoidArrayLoops - Yasar Shaikh (@yasarshaikh)
- #4150: [apex] New rule ApexUnitTestClassShouldHaveRunAs #4149 - Thomas Prouvot (@tprouvot)
Stats
- 63 commits
- 28 closed tickets & PRs
- Days since last release: 28
PMD 6.50.0 (30-September-2022)
30-September-2022 - 6.50.0
The PMD team is pleased to announce PMD 6.50.0.
This is a minor release.
Table Of Contents
New and noteworthy
Lua now supports additionally Luau
This release of PMD adds support for Luau, a gradually typed language derived
from Lua. This means, that the Lua language in PMD can now parse both Lua and Luau.
Modified rules
- The Java rule
UnusedPrivateField
now ignores private fields, if the fields are
annotated with any annotation or the enclosing class has any annotation. Annotations often enable a
framework (such as dependency injection, mocking or e.g. Lombok) which use the fields by reflection or other
means. This usage can't be detected by static code analysis. Previously these frameworks where explicitly allowed
by listing their annotations in the property "ignoredAnnotations", but that turned out to be prone of false
positive for any not explicitly considered framework. That's why the property "ignoredAnnotations" has been
deprecated for this rule. - The Java rule
CommentDefaultAccessModifier
now by default ignores JUnit5 annotated
methods. This behavior can be customized using the propertyignoredAnnotations
.
Fixed Issues
- cli
- #4118: [cli] run.sh designer reports "integer expression expected"
- core
- #4116: [core] Missing --file arg in TreeExport CLI example
- doc
- java
- #3431: [java] Add sample java project to regression-tester which uses new language constructs
- java-bestpractices
- java-codestyle
- #3859: [java] CommentDefaultAccessModifier is triggered in JUnit5 test class
- #4085: [java] UnnecessaryFullyQualifiedName false positive when nested and non-nested classes with the same name and in the same package are used together
- #4133: [java] UnnecessaryFullyQualifiedName - FP for inner class pkg.ClassA.Foo implementing pkg.Foo
- java-design
- #4090: [java] FinalFieldCouldBeStatic false positive with non-static synchronized block (regression in 6.48, worked with 6.47)
- java-errorprone
- scala
- #4138: [scala] Upgrade scala-library to 2.12.7 / 2.13.9 and scalameta to 4.6.0
API Changes
CPD CLI
- CPD now supports the
--ignore-literal-sequences
argument when analyzing Lua code.
Financial Contributions
Many thanks to our sponsors:
External Contributions
- #4066: [lua] Add support for Luau syntax and skipping literal sequences in CPD - Matt Hargett (@matthargett)
- #4100: [java] Update UnusedPrivateFieldRule - ignore any annotations - Lynn (@LynnBroe)
- #4116: [core] Fix missing --file arg in TreeExport CLI example - mohan-chinnappan-n (@mohan-chinnappan-n)
- #4124: [doc] Fix typos in Java rule docs - Piotrek Żygieło (@pzygielo)
- #4128: [java] Fix False-positive UnnecessaryFullyQualifiedName when nested and non-nest… #4103 - Oleg Andreych (@OlegAndreych)
- #4130: [ci] GitHub Workflows security hardening - Alex (@sashashura)
- #4131: [doc] TooFewBranchesForASwitchStatement - Use "if-else" instead of "if-then" - Suvashri (@Suvashri)
- #4137: [java] Fixes 3859: Exclude junit5 test methods from the commentDefaultAccessModifierRule - Luis Alcantar (@lfalcantar)
Stats
- 100 commits
- 26 closed tickets & PRs
- Days since last release: 29
PMD 6.49.0 (31-August-2022)
31-August-2022 - 6.49.0
The PMD team is pleased to announce PMD 6.49.0.
This is a minor release.
Table Of Contents
New and noteworthy
Updated PMD Designer
This PMD release ships a new version of the pmd-designer.
For the changes, see PMD Designer Changelog.
Fixed Issues
- apex
- #4096: [apex] ApexAssertionsShouldIncludeMessage and ApexUnitTestClassShouldHaveAsserts: support new Assert class (introduced with Apex v56.0)
- core
- #3970: [core] FileCollector.addFile ignores language parameter
- java-codestyle
- #4082: [java] UnnecessaryImport false positive for on-demand imports of nested classes
API Changes
Deprecated API
-
In order to reduce the dependency on Apex Jorje classes, the following methods have been deprecated.
These methods all leaked internal Jorje enums. These enums have been replaced now by enums the
PMD's AST package.ASTAssignmentExpression#getOperator
ASTBinaryExpression#getOperator
ASTBooleanExpression#getOperator
ASTPostfixExpression#getOperator
ASTPrefixExpression#getOperator
All these classes have now a new
getOp()
method. Existing code should be refactored to use this method instead.
It returns the new enums, likeAssignmentOperator
, and avoids
the dependency to Jorje.
External Contributions
- #4081: [apex] Remove Jorje leaks outside
ast
package - @eklimo - #4083: [java] UnnecessaryImport false positive for on-demand imports of nested classes (fix for #4082) - @abyss638
- #4092: [apex] Implement ApexQualifiableNode for ASTUserEnum - @aaronhurst-google
- #4095: [core] CPD: Added begin and end token to XML reports - @pacvz
- #4097: [apex] ApexUnitTestClassShouldHaveAssertsRule: Support new Assert class (Apex v56.0) - @tprouvot
- #4104: [doc] Add MegaLinter in the list of integrations - @nvuillam
Stats
- 49 commits
- 10 closed tickets & PRs
- Days since last release: 32
PMD 6.48.0 (30-July-2022)
30-July-2022 - 6.48.0
The PMD team is pleased to announce PMD 6.48.0.
This is a minor release.
Table Of Contents
New and noteworthy
Java 19 Support
This release of PMD brings support for Java 19. There are no new standard language features.
PMD supports JEP 427: Pattern Matching for switch (Third Preview) and
JEP 405: Record Patterns (Preview) as preview language features.
In order to analyze a project with PMD that uses these language features,
you'll need to enable it via the environment variable PMD_JAVA_OPTS
and select the new language
version 19-preview
:
export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd -language java -version 19-preview ...
Note: Support for Java 17 preview language features have been removed. The version "17-preview" is no longer available.
Gherkin support
Thanks to the contribution from Anne Brouwers PMD now has CPD support
for the Gherkin language. It is used to defined test cases for the
Cucumber testing tool for behavior-driven development.
Being based on a proper Antlr grammar, CPD can:
- ignore comments
- honor comment-based suppressions
Fixed Issues
- apex
- #4056: [apex] ApexSOQLInjection: Add support count query
- core
- #3796: [core] CPD should also provide a
--debug
flag - #4021: [core] CPD: Add total number of tokens to XML reports
- #4031: [core] If report is written to stdout, stdout should not be closed
- #4051: [doc] Additional rulesets are not listed in documentation
- #4053: [core] Allow building PMD under Java 18+
- #3796: [core] CPD should also provide a
- java
- #4015: [java] Support JDK 19
- java-bestpractices
- #3455: [java] WhileLoopWithLiteralBoolean - false negative with complex expressions
- java-design
- java-performance
- #3625: [java] AddEmptyString - false negative with empty var
- lua
- #4061: [lua] Fix several related Lua parsing issues found when using CPD
- test
API Changes
CPD CLI
- CPD has a new CLI option
--debug
. This option has the same behavior as in PMD. It enables more verbose
logging output.
Rule Test Framework
- The module "pmd-test", which contains support classes to write rule tests, now requires Java 8. If you depend on
this module for testing your own custom rules, you'll need to make sure to use at least Java 8. - The new module "pmd-test-schema" contains now the XSD schema and the code to parse the rule test XML files. The
schema has been extracted in order to easily share it with other tools like the Rule Designer or IDE plugins. - Test schema changes:
- The attribute
isRegressionTest
oftest-code
is deprecated. The new
attributedisabled
should be used instead for defining whether a rule test should be skipped or not. - The attributes
reinitializeRule
anduseAuxClasspath
oftest-code
are deprecated and assumed true.
They will not be replaced. - The new attribute
focused
oftest-code
allows disabling all tests except the focused one temporarily.
- The attribute
- More information about the rule test framework can be found in the documentation:
Testing your rules
Deprecated API
- The experimental Java AST class
ASTGuardedPattern
has been deprecated and
will be removed. It was introduced for Java 17 and Java 18 Preview as part of pattern matching for switch,
but it is no longer supported with Java 19 Preview. - The interface
CPDRenderer
is deprecated. For custom CPD renderers
the new interfaceCPDReportRenderer
should be used. - The class
TestDescriptor
is deprecated, replaced withRuleTestDescriptor
. - Many methods of
RuleTst
have been deprecated as internal API.
Experimental APIs
- To support the Java preview language features "Pattern Matching for Switch" and "Record Patterns", the following
AST nodes have been introduced as experimental:
Internal API
Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0.
You can identify them with the @InternalApi
annotation. You'll also get a deprecation warning.
CPDConfiguration#setRenderer
CPDConfiguration#setCPDRenderer
CPDConfiguration#getRenderer
CPDConfiguration#getCPDRenderer
CPDConfiguration#getRendererFromString
CPDConfiguration#getCPDRendererFromString
CPDRendererAdapter
Financial Contributions
Many thanks to our sponsors:
External Contributions
- #3984: [java] Fix AddEmptyString false-negative issue - @LiGaOg
- #3988: [java] Modify WhileLoopWithLiteralBoolean to meet the missing case #3455 - @VoidxHoshi
- #3992: [java] FinalFieldCouldBeStatic - fix false negative with unnecessary parenthesis - @dalizi007
- #3994: [java] TooManyMethods - improve getter/setter detection (#3729) - @341816041
- #4017: Add Gherkin support to CPD - @ASBrouwers
- #4021: [core] CPD: Add total number of tokens to XML reports - @maikelsteneker
- #4056: [apex] ApexSOQLInjection: Add support count query - @gwilymatgearset
- #4061: [lua] Fix several related Lua parsing issues found when using CPD - @matthargett
Stats
- 102 commits
- 26 closed tickets & PRs
- Days since last release: 35
PMD 6.47.0 (25-June-2022)
25-June-2022 - 6.47.0
The PMD team is pleased to announce PMD 6.47.0.
This is a minor release.
Table Of Contents
Fixed Issues
- core
- java-bestpractices
- java-design
- #3823: [java] ImmutableField: Do not flag fields in @Entity
- #3981: [java] ImmutableField reports fields annotated with @Value (Spring)
- #3998: [java] ImmutableField reports fields annotated with @Captor (Mockito)
- #4004: [java] ImmutableField reports fields annotated with @GwtMock (GwtMockito) and @Spy (Mockito)
- #4008: [java] ImmutableField not reporting fields that are only initialized in the declaration
- #4011: [java] ImmutableField: Do not flag fields annotated with @Inject
- #4020: [java] ImmutableField reports fields annotated with @FindBy and @FindBys (Selenium)
- java-errorprone
API Changes
No changes.
External Contributions
- #3985: [java] Fix false negative problem about Enum in AvoidFieldNameMatchingMethodName #3936 - @Scrsloota
- #3993: [java] AvoidDuplicateLiterals - Add the method "buz" definition to test cases - @dalizi007
- #4002: [java] ImmutableField - Ignore fields annotated with @Value (Spring) or @Captor (Mockito) - @jjlharrison
- #4003: [java] UnusedPrivateField - Ignore fields annotated with @Id/@EmbeddedId/@Version (JPA) or @Mock/@Spy/@MockBean (Mockito/Spring) - @jjlharrison
- #4006: [doc] Fix eclipse plugin update site URL - @shiomiyan
- #4010: [core] Bump kotlin to version 1.7.0 - @maikelsteneker
Stats
- 45 commits
- 23 closed tickets & PRs
- Days since last release: 27