30-April-2022 - 6.45.0-SNAPSHOT
The PMD team is pleased to announce PMD 6.45.0-SNAPSHOT.
This is a minor release.
New and noteworthy
Support for HTML
This version of PMD ships a new language module to support analyzing of HTML. Support for HTML is experimental and might change without notice. The language implementation is not complete yet and the AST doesn’t look well for text nodes and comment nodes and might be changed in the future. You can write your own rules, but we don’t guarantee that the rules work with the next (minor) version of PMD without adjustments.
Please give us feedback about how practical this new language is in discussions. Please report missing features or bugs as new issues.
New rules
- The HTML rule
AvoidInlineStyles
finds elements which use a style attribute. In order to help maintaining a webpage it is considered good practice to separate content and styles. Instead of inline styles one should use CSS files and classes.
<rule ref="category/html/bestpractices.xml/AvoidInlineStyles" />
- The HTML rule
UnnecessaryTypeAttribute
finds “link” and “script” elements which still have a “type” attribute. This is not necessary anymore since modern browsers automatically use CSS and JavaScript.
<rule ref="category/html/bestpractices.xml/UnnecessaryTypeAttribute" />
- The HTML rule
UseAltAttributeForImages
finds “img” elements without an “alt” attribute. An alternate text should always be provided in order to help screen readers.
<rule ref="category/html/bestpractices.xml/UseAltAttributeForImages" />
Modified rules
- The Java rule
UnusedPrivateField
has a new propertyignoredFieldNames
. The default ignores serialization-specific fields (egserialVersionUID
). The property can be used to ignore more fields based on their name. Note that the rule used to ignore fields namedIDENT
, but doesn’t anymore (add this value to the property to restore the old behaviour).
Fixed Issues
- core
- doc
- #2505: [doc] Improve side bar to show release date
- java
- java-bestpractices
- #3910: [java] UnusedPrivateField - Allow the ignored fieldnames to be configurable
- #1185: [java] ArrayIsStoredDirectly false positive with field access
- #1474: [java] ArrayIsStoredDirectly false positive with method call
- #3879 [java] ArrayIsStoredDirectly reports duplicated violation
- #3929: [java] ArrayIsStoredDirectly should report the assignment rather than formal parameter
- java-design
- #3603: [java] SimplifiedTernary: no violation for ‘condition ? true : false’ case
- java-performance
- #3867: [java] UseArraysAsList with method call
- plsql
API Changes
Experimental APIs
- Report has two new methods which allow limited mutations of a given report:
Report#filterViolations
creates a new report with some violations removed with a given predicate based filter.Report#union
can combine two reports into a single new Report.
net.sourceforge.pmd.util.Predicate
will be replaced in PMD7 with the standard Predicate interface from java8.- The module
pmd-html
is entirely experimental right now. Anything in the packagenet.sourceforge.pmd.lang.html
should be used cautiously.
External Contributions
- #3883: [doc] Improve side bar by Adding Release Date - @jasonqiu98
- #3910: [java] UnusedPrivateField - Allow the ignored fieldnames to be configurable - @laoseth
- #3928: [plsql] Fix plsql parsing error in parenthesis groups - @LiGaOg
- #3935: [plsql] Fix parser exception in EXECUTE IMMEDIATE BULK COLLECT #3687 - @Scrsloota
- #3938: [java] Modify SimplifiedTernary to meet the missing case #3603 - @VoidxHoshi
- #3943: chore: Set permissions for GitHub actions - @naveensrinivasan