24 January 2020
The PMD team is pleased to announce PMD 6.21.0.
This is a minor release.
Thanks to Anatoly Trosinenko PMD supports now a new language: Modelica is a language to model complex physical systems. Both PMD and CPD are supported and there are already 3 rules available. The PMD Designer supports syntax highlighting for Modelica.
While the language implementation is quite complete, Modelica support is considered experimental for now. This is to allow us to change the rule API (e.g. the AST classes) slightly and improve the implementation based on your feedback.
We added a experimental feature to dump the AST of a source file into XML. The XML format is of course PMD specific and language dependent. That XML file can be used to execute (XPath) queries against without PMD. It can also be used as a textual visualization of the AST if you don’t want to use the Designer.
This feature is experimental and might change or even be removed in the future, if it is not useful. A short description how to use it is available under Creating XML dump of the AST.
Any feedback about it, especially about your use cases, is highly appreciated.
The CPD XML output format has been enhanced to also report column information for found duplications in addition to the line information. This allows to display the exact tokens, that are considered duplicate.
If a CPD language doesn’t provide these exact information, then these additional attributes are omitted.
Each <file>
element in the XML format now has 3 new attributes:
endLine
beginColumn
(if there is column information available)endColumn
(if there is column information available)The Java rule AvoidLiteralsInIfCondition
(java-errorprone
) has a new property
ignoreExpressions
. This property is set by default to true
in order to maintain compatibility. If this
property is set to false, then literals in more complex expressions are considered as well.
The Apex rule ApexCSRF
(apex-errorprone
) has been moved from category
“Security” to “Error Prone”. The Apex runtime already prevents DML statements from being executed, but only
at runtime. So, if you try to do this, you’ll get an error at runtime, hence this is error prone. See also
the discussion on #2064.
The Java rule CommentRequired
(java-documentation
) has a new property
classCommentRequirement
. This replaces the now deprecated property headerCommentRequirement
, since
the name was misleading. (File) header comments are not checked, but class comments are.
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
RuleViolationFactory
in each
language module, eg JavaRuleViolationFactory
.
See javadoc of RuleViolationFactory
.Implementations of RuleViolation
in each language module,
eg JavaRuleViolation
. See javadoc of
RuleViolation
.
RuleFactory
RuleBuilder
RuleSetFactory
, use factory methods from RulesetsFactoryUtils
insteadAbstractApexNode
AbstractApexNodeBase
, and the related visit
methods on ApexParserVisitor
and its implementations.
Use ApexNode
instead, now considers comments too.
CharStream
, JavaCharStream
,
SimpleCharStream
: these are APIs used by our JavaCC
implementations and that will be moved/refactored for PMD 7.0.0. They should not
be used, extended or implemented directly.JJTJavaParserState
.
This includes token classes, which will be replaced with a single implementation, and
subclasses of ParseException
, whose usages will be replaced
by just that superclass.Node
interface
and AbstractNode
base class. See their javadoc for details.Node#isFindBoundary
is deprecated for XPath queries.AbstractJavaParser
AbstractJavaHandler
ASTAnyTypeDeclaration.TypeKind
ASTAnyTypeDeclaration#getKind
JavaQualifiedName
ASTCatchStatement#getBlock
ASTCompilationUnit#declarationsAreInDefaultPackage
JavaQualifiableNode
net.sourceforge.pmd.lang.java.qname
and its contentsMethodLikeNode
ASTMethodOrConstructorDeclaration
,
ASTLambdaExpression
.ASTAnyTypeDeclaration#getImage
will be removed. Please use getSimpleName()
instead. This affects ASTAnnotationTypeDeclaration#getImage
,
ASTClassOrInterfaceDeclaration#getImage
, and
ASTEnumDeclaration#getImage
.ASTTryStatement
, replacements with other names
have been added. This includes the XPath attribute @Finally
, replace it with a test for child::FinallyStatement
.getGuardExpressionNode
are replaced with getCondition
. This affects the
following nodes: WhileStatement, DoStatement, ForStatement, IfStatement, AssertStatement, ConditionalExpression.ASTYieldStatement
will not implement TypeNode
anymore come 7.0.0. Test the type of the expression nested within it.