??-????-2020 - 6.22.0
The PMD team is pleased to announce PMD 6.22.0.
This is a minor release.
New and noteworthy
Updated PMD Designer
This PMD release ships a new version of the pmd-designer. For the changes, see PMD Designer Changelog.
Apex Suppressions
In addition to suppressing violation with the @SuppressWarnings
annotation, Apex now also supports
the suppressions with a NOPMD
comment. See Suppressing warnings.
New Rules
- The Rule
CognitiveComplexity
(apex-design
) finds methods and classes that are highly complex and therefore difficult to read and more costly to maintain. In contrast to cyclomatic complexity, this rule uses “Cognitive Complexity”, which is a measure of how difficult it is for humans to read and understand a method.
Fixed Issues
- apex
- apex-design
- #2162: [apex] Cognitive Complexity rule
- doc
- #2274: [doc] Java API documentation for PMD
- java
- #2268: [java] Improve TypeHelper resilience
- java-bestpractices
- #2277: [java] FP in UnusedImports for ambiguous static on-demand imports
- java-design
- #911: [java] UselessOverridingMethod false positive when elevating access modifier
- java-errorprone
- java-performance
- #2275: [java] AppendCharacterWithChar flags literals in an expression
API Changes
Deprecated APIs
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.
JavaLanguageHandler
JavaLanguageParser
JavaDataFlowHandler
- Implementations of
RuleViolationFactory
in each language module, egJavaRuleViolationFactory
. See javadoc ofRuleViolationFactory
. -
Implementations of
RuleViolation
in each language module, egJavaRuleViolation
. See javadoc ofRuleViolation
. RuleFactory
RuleBuilder
- Constructors of
RuleSetFactory
, use factory methods fromRulesetsFactoryUtils
instead AbstractApexNode
AbstractApexNodeBase
, and the relatedvisit
methods onApexParserVisitor
and its implementations. UseApexNode
instead, now considers comments too.
For removal
- pmd-core
DFAGraphRule
and its implementationsDFAGraphMethod
- Many methods on the
Node
interface andAbstractNode
base class. See their javadoc for details. Node#isFindBoundary
is deprecated for XPath queries.- Many APIs of
net.sourceforge.pmd.lang.metrics
, though most of them were internal and probably not used directly outside of PMD. UseMetricsUtil
as a replacement for the language-specific façades too. QualifiableNode
,QualifiedName
- pmd-java
AbstractJavaParser
AbstractJavaHandler
ASTAnyTypeDeclaration.TypeKind
ASTAnyTypeDeclaration#getKind
JavaQualifiedName
ASTCatchStatement#getBlock
ASTCompilationUnit#declarationsAreInDefaultPackage
JavaQualifiableNode
net.sourceforge.pmd.lang.java.qname
and its contentsMethodLikeNode
- Its methods will also be removed from its implementations,
ASTMethodOrConstructorDeclaration
,ASTLambdaExpression
.
- Its methods will also be removed from its implementations,
ASTAnyTypeDeclaration#getImage
will be removed. Please usegetSimpleName()
instead. This affectsASTAnnotationTypeDeclaration#getImage
,ASTClassOrInterfaceDeclaration#getImage
, andASTEnumDeclaration#getImage
.- Several methods of
ASTTryStatement
, replacements with other names have been added. This includes the XPath attribute@Finally
, replace it with a test forchild::FinallyStatement
. - Several methods named
getGuardExpressionNode
are replaced withgetCondition
. This affects the following nodes: WhileStatement, DoStatement, ForStatement, IfStatement, AssertStatement, ConditionalExpression. ASTYieldStatement
will not implementTypeNode
anymore come 7.0.0. Test the type of the expression nested within it.JavaMetrics
,JavaMetricsComputer
ASTArguments#getArgumentCount
. Usesize
instead.ASTFormalParameters#getParameterCount
. Usesize
instead.
- pmd-apex
External Contributions
- #2251: [java] FP for InvalidLogMessageFormat when using slf4j-Markers - Kris Scheibe
- #2253: [modelica] Remove duplicated dependencies - Piotrek Żygieło
- #2256: [doc] Corrected XML attributes in release notes - Maikel Steneker
- #2276: [java] AppendCharacterWithCharRule ignore literals in expressions - Kris Scheibe
- #2278: [java] fix UnusedImports rule for ambiguous static on-demand imports - Kris Scheibe
- #2279: [apex] Add support for suppressing violations using the // NOPMD comment - Gwilym Kuiper
- #2297: [apex] Cognitive complexity metrics - Gwilym Kuiper