An extensible multilanguage static code analyzer.
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.
The new official logo of PMD:
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)
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 Designerpmd check
For more information, see the Detailed Release Notes for PMD 7.
Contributors: Juan Martín Sotuyo Dodero (@jsotuyod)
For more information, see the Detailed Release Notes for PMD 7.
Contributors: Lucas Soncini (@lsoncini), Matías Fraga (@matifraga), Tomás De Lucca (@tomidelucca)
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.
Contributors: Lucas Soncini (@lsoncini), Matías Fraga (@matifraga), Tomás De Lucca (@tomidelucca)
minimumLanguageVersion
and
maximumLanguageVersion
attributes.Apex
UnusedMethod
finds unused methods in your code.Java
UnnecessaryBoxing
reports boxing and unboxing conversions that may be made implicit.Kotlin
Swift
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. With ignoreClarifying
(default: true) parentheses that are strictly speaking
not necessary are allowed, if they separate expressions of different precedence.
The other property ignoreBalancing
(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
and InterruptedException
are not
special-cased anymore. Rename the exception parameter to ignored
to ignore them.DontImportSun
: sun.misc.Signal
is not special-cased anymore.UseDiamondOperator
: the property java7Compatibility
is removed. The rule now
handles Java 7 properly without a property.SingularField
: Properties checkInnerClasses
and disallowNotAssignment
are removed.
The rule is now more precise and will check these cases properly.UseUtilityClass
: The property ignoredAnnotations
has been removed.LawOfDemeter
: the rule has a new property trustRadius
. This defines the maximum degree
of trusted data. The default of 1 is the most restrictive.CommentContent
: The properties caseSensitive
and disallowedTerms
are removed. The
new property fobiddenRegex
can be used now to define the disallowed terms with a single regular
expression.Many rules, that were previously deprecated have been finally removed. See Detailed Release Notes for PMD 7 for the complete list.
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 detailed description of the changes listed here, see Detailed Release Notes for PMD 7.
See Detailed Release Notes for PMD 7.
isFindBoundary
should not be an attributeLanguage specific fixes:
@SuppressWarnings
with constants instead of literalsisOverridden
in ASTMethodDeclarationfoo.bar().size()
Throwable.addSuppressed(...)
new BigDecimal(Expression)
The PMD team is pleased to announce PMD 6.55.0.
This is a minor release.
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.
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 ...
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:
net.sourceforge.pmd.lang.java.ast.ASTGuardedPattern
has been removed.The PMD team is pleased to announce PMD 6.54.0.
This is a minor release.
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.
--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.ApexRootNode#getApexVersion
has been deprecated for removal. The version returned is
always Version.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
for CPDConfiguration
which extends AbstractConfiguration
.
BaseCLITest
and BaseCPDCLITest
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
by FileCollector#addZipFileWithContent
which directly adds the
content of the zip file for analysis.
PMDConfiguration#setReportShortNames
and
PMDConfiguration#isReportShortNames
have been deprecated for removal.
Use PMDConfiguration#addRelativizeRoot
instead.
CSVWriter
AbstractAntTestHelper
filterMatches
creates a new CPD report
with some matches removed with a given predicate based filter.The PMD team is pleased to announce PMD 6.53.0.
This is a minor release.
UnusedPrivateField
has a new property reportForAnnotations
.
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.The Java rules ExcessiveClassLength
and ExcessiveMethodLength
have been deprecated. The rule NcssCount
can be used instead.
The deprecated rules will be removed with PMD 7.0.0.
The Java rule EmptyStatementNotInLoop
is deprecated.
Use the rule UnnecessarySemicolon
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.
These classes / APIs have been deprecated and will be removed with PMD 7.0.0.
ExcessiveLengthRule
(Java)The PMD team is pleased to announce PMD 6.52.0.
This is a minor release.
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"/>
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.
The rule ClassNamingConventions
has a new property testClassPattern
, 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 rule ImmutableField
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.
ignoredAnnotations
PMD now supports a new --use-version
flag, which receives a language-version pair (such as java-8
or apex-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
.
-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.Using run.sh cpdgui
will now warn about it being deprecated. Use run.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 use run.sh ast-dump
for a text-based alternative.
The following core APIs have been marked as deprecated for removal in PMD 7:
PMD
and PMD.StatusCode
- PMD 7 will ship with a revamped CLI split from pmd-core. To programmatically launch analysis you can use PmdAnalysis
.PMDConfiguration#getAllInputPaths
- It is now superseded by PMDConfiguration#getInputPathList
PMDConfiguration#setInputPaths
- It is now superseded by PMDConfiguration#setInputPathList
PMDConfiguration#addInputPath
- It is now superseded by PMDConfiguration#addInputPath
PMDConfiguration#getInputFilePath
- It is now superseded by PMDConfiguration#getInputFile
PMDConfiguration#getIgnoreFilePath
- It is now superseded by PMDConfiguration#getIgnoreFile
PMDConfiguration#setInputFilePath
- It is now superseded by PMDConfiguration#setInputFilePath
PMDConfiguration#setIgnoreFilePath
- It is now superseded by PMDConfiguration#setIgnoreFilePath
PMDConfiguration#getInputUri
- It is now superseded by PMDConfiguration#getUri
PMDConfiguration#setInputUri
- It is now superseded by PMDConfiguration#setInputUri
PMDConfiguration#getReportFile
- It is now superseded by PMDConfiguration#getReportFilePath
PMDConfiguration#setReportFile
- It is now superseded by PMDConfiguration#setReportFile
PMDConfiguration#isStressTest
and PMDConfiguration#setStressTest
- Will be removed with no replacement.PMDConfiguration#isBenchmark
and PMDConfiguration#setBenchmark
- Will be removed with no replacement, the CLI will still support it.CPD
and CPD.StatusCode
- PMD 7 will ship with a revamped CLI split from pmd-core. An alterative to programatically launch CPD analysis will be added in due time.In order to reduce the dependency on Apex Jorje classes, the method DataType#fromBasicType
has been deprecated. The equivalent method fromTypeName
should be used instead.
The PMD team is pleased to announce PMD 6.51.0.
This is a minor release.
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.
TestClassWithoutTestCases
has a new property testClassPattern
. 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.No changes.
The PMD team is pleased to announce PMD 6.50.0.
This is a minor release.
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.
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.CommentDefaultAccessModifier
now by default ignores JUnit5 annotated
methods. This behavior can be customized using the property ignoredAnnotations
.--ignore-literal-sequences
argument when analyzing Lua code.Many thanks to our sponsors: