??-????-2020 - 6.27.0-SNAPSHOT
The PMD team is pleased to announce PMD 6.27.0-SNAPSHOT.
This is a minor release.
New and noteworthy
Changes in how tab characters are handled
In the past, tab characters in source files has been handled differently in different languages by PMD. For instance in Java, tab characters had a width of 8 columns, while C# used only 1 column. Visualforce instead used 4 columns.
This has been unified now so that tab characters are consistently now always 1 column wide.
This however might be a incompatible change, if you’re using the properties “BeginColumn” or “EndColumn” additionally to “BeginLine” and “EndLine” of a Token/AST node in order to highlight where a rule violation occurred in the source file. If you have logic there that deals with tab characters, you most likely can remove this logic now, since tab characters are now just “normal” characters in terms of string processing.
See also [all] Ensure PMD/CPD uses tab width of 1 for tabs consistently #2656.
New Rules
- The new Java rule
AvoidReassigningCatchVariables
(java-bestpractices
) finds cases where the variable of the caught exception is reassigned. This practice is surprising and prevents further evolution of the code like multi-catch.
Deprecated Rules
- The Java rule
DataflowAnomalyAnalysis
(java-errorprone
) is deprecated in favour ofUnusedAssignment
(java-bestpractices
), which was introduced in PMD 6.26.0.
Fixed Issues
- core
- java-bestpractices
- java-errorprone
- #2431: [java] InvalidLogMessageFormatRule throws IndexOutOfBoundsException when only logging exception message
- #2439: [java] AvoidCatchingThrowable can not detect the case: catch (java.lang.Throwable t)
- #2531: [java] UnnecessaryCaseChange can not detect the case like: foo.equals(bar.toLowerCase())
- #2647: [java] Deprecate rule DataFlowAnomalyAnalysis
- java-performance
API Changes
- XML rule definition in rulesets: In PMD 7, the
language
attribute will be required on allrule
elements that declare a new rule. Some base rule classes set the language implicitly in their constructor, and so this is not required in all cases for the rule to work. But this behavior will be discontinued in PMD 7, so missinglanguage
attributes are now reported as a forward compatibility warning.
Deprecated API
For removal
Rule#getParserOptions
Parser#getParserOptions
net.sourceforge.pmd.lang.AbstractParser
RuleContext#removeAttribute
RuleContext#getAttribute
RuleContext#setAttribute
ApexParserOptions
ASTThrowStatement#getFirstClassOrInterfaceTypeImage
EcmascriptParserOptions
EcmascriptXPathRule
XmlParserOptions
XmlXPathRule
-
Properties of
AbstractXmlRule
net.sourceforge.pmd.Report.ReadableDuration
-
Many methods of
net.sourceforge.pmd.Report
. They are replaced by accessors that produce a List. For example,iterator()
(and implementing Iterable) andisEmpty()
are both replaced bygetViolations()
. - The dataflow codebase is deprecated for removal in PMD 7. This includes all code in the following packages, and their subpackages:
net.sourceforge.pmd.lang.vf.VfSimpleCharStream
External Contributions
- #2656: [all] Ensure PMD/CPD uses tab width of 1 for tabs consistently - Maikel Steneker
- #2659: [java] StringToString can not detect the case: getStringMethod().toString() - Mykhailo Palahuta
- #2662: [java] UnnecessaryCaseChange can not detect the case like: foo.equals(bar.toLowerCase()) - Mykhailo Palahuta
- #2677: [java] RedundantFieldInitializer can not detect a special case for char initialize:
char foo = '\0';
- Mykhailo Palahuta - #2678: [java] AvoidCatchingThrowable can not detect the case: catch (java.lang.Throwable t) - Mykhailo Palahuta
- #2679: [java] InvalidLogMessageFormatRule throws IndexOutOfBoundsException when only logging exception message - Mykhailo Palahuta
- #2682: [java] New Rule: AvoidReassigningCatchVariables - Mykhailo Palahuta