??-August-2019 - 6.18.0
The PMD team is pleased to announce PMD 6.18.0.
This is a minor release.
New and noteworthy
New rule designer documentation
The documentation for the rule designer is now available on the main PMD documentation page: Rule Designer Reference. Check it out to learn about the usage and features of the rule designer.
New rules
- The Java rule
AvoidMessageDigestField
(java-bestpractices
) detects fields of the typejava.security.MessageDigest
. Using a message digest instance as a field would need to be synchronized, as it can easily be used by multiple threads. Without synchronization the calculated hash could be entirely wrong. Instead of declaring this as a field and synchronize access to use it from multiple threads, a new instance should be created when needed. This rule is also active when using java’s quickstart ruleset.
Modified Rules
- The Java rule
CloseResource
(java-errorprone
) now ignores by default instances ofjava.util.stream.Stream
. These streams areAutoCloseable
, but most streams are backed by collections, arrays, or generating functions, which require no special resource management. However, there are some exceptions: The stream returned byFiles::lines(Path)
is backed by a actual file and needs to be closed. These instances won’t be found by default by the rule anymore.
Fixed Issues
- all
- #1465: [core] Stylesheet pmd-report.xslt fails to display filepath if ‘java’ in path
- #1923: [core] Incremental analysis does not work with shortnames
- #1983: [core] Avoid crashes with analysis cache when classpath references non-existing directories
- #1990: [core] Incremental analysis mixes XPath rule violations
- java-bestpractices
- java-codestyle
- #1951: [java] UnnecessaryFullyQualifiedName rule triggered when variable name clashes with package name
- java-errorprone
API Changes
Changes to Renderer
-
Each renderer has now a new method
Renderer#setUseShortNames
which is used for implementing the “shortnames” CLI option. The method is automatically called by PMD, if this CLI option is in use. When rendering filenames to the report, the new helper methodAbstractRenderer#determineFileName
should be used. This will change the filename to a short name, if the CLI option “shortnames” is used.Not adjusting custom renderers will make them render always the full file names and not honoring the CLI option “shortnames”.
Deprecated APIs
For removal
- The methods
getImportedNameNode
andgetPackage
have been deprecated and will be removed with PMD 7.0.0. - The method
RuleContext#setSourceCodeFilename
has been deprecated and will be removed. The already existing methodRuleContext#setSourceCodeFile
should be used instead. The methodRuleContext#getSourceCodeFilename
still exists and returns just the filename without the full path. - The method
AbstractPMDProcessor#filenameFrom
has been deprecated. It was used to determine a “short name” of the file being analyzed, so that the report can use short names. However, this logic has been moved to the renderers. - The method
Report#metrics
andReport
have been deprecated. They were leftovers from a previous deprecation round targetingStatisticalRule
.
Internal APIs
- The contents of the package
net.sourceforge.pmd.cache
have been marked@InternalApi
. That subsystem is very low-level and is not intended for public use. It will be hidden with PMD 7.0.0.
External Contributions
- #1970: [java] DoubleBraceInitialization: Fix example - Tobias Weimer
- #1971: [java] 1862 - Message Digest should not be used as class field - AnthonyKot
- #1994: [core] Resolve pmd-report failure when java folder in filepath - Amish Shah