2017-08-15 14:08:48 +02:00
|
|
|
---
|
|
|
|
title: PMD Release Notes
|
|
|
|
permalink: pmd_release_notes.html
|
|
|
|
keywords: changelog, release notes
|
|
|
|
---
|
2014-01-03 11:55:46 +01:00
|
|
|
|
2018-09-02 14:30:21 +02:00
|
|
|
## {{ site.pmd.date }} - {{ site.pmd.version }}
|
2016-04-23 18:30:13 +02:00
|
|
|
|
2018-08-14 17:07:53 +02:00
|
|
|
The PMD team is pleased to announce PMD {{ site.pmd.version }}.
|
2016-07-27 22:03:51 +02:00
|
|
|
|
2018-08-14 17:07:53 +02:00
|
|
|
This is a {{ site.pmd.release_type }} release.
|
2016-07-07 20:48:01 +02:00
|
|
|
|
2018-09-30 10:47:07 +02:00
|
|
|
{% tocmaker is_release_notes_processor %}
|
2017-04-29 20:22:28 +02:00
|
|
|
|
2019-11-29 20:05:59 +01:00
|
|
|
### New and noteworthy
|
|
|
|
|
2021-04-29 14:59:13 +02:00
|
|
|
#### Javascript module now requires at least Java 8
|
|
|
|
|
|
|
|
The latest version of [Rhino](https://github.com/mozilla/rhino), the implementation of JavaScript we use
|
|
|
|
for parsing JavaScript code, requires at least Java 8. Therefore we decided to upgrade the pmd-javascript
|
2021-05-21 11:00:48 +02:00
|
|
|
module to Java 8 as well. This means that from now on, a Java 8 or later runtime is required in order
|
|
|
|
to analyze JavaScript code. Note that PMD core still only requires Java 7.
|
2021-04-29 14:59:13 +02:00
|
|
|
|
2021-05-25 13:12:12 +02:00
|
|
|
#### New rules
|
|
|
|
|
2021-05-28 12:34:32 +02:00
|
|
|
This release ships with 3 new Java rules.
|
|
|
|
|
|
|
|
* {% rule "java/bestpractices/JUnit5TestShouldBePackagePrivate" %}
|
2021-05-25 13:12:12 +02:00
|
|
|
enforces the convention that JUnit 5 tests should have minimal visibility.
|
|
|
|
You can try out this rule like so:
|
|
|
|
```xml
|
|
|
|
<rule ref="category/java/bestpractices.xml/JUnit5TestShouldBePackagePrivate" />
|
|
|
|
```
|
|
|
|
|
2021-05-28 12:34:32 +02:00
|
|
|
* {% rule "java/design/CognitiveComplexity" %} uses the cognitive complexity
|
|
|
|
metric to find overly complex code. This metric improves on the similar cyclomatic complexity
|
|
|
|
in several ways, for instance, it incentivizes using clearly readable shorthands and idioms.
|
|
|
|
See the rule documentation for more details. You can try out this rule like so:
|
|
|
|
```xml
|
|
|
|
<rule ref="category/java/design.xml/CognitiveComplexity" />
|
|
|
|
```
|
|
|
|
|
|
|
|
* {% rule "java/design/MutableStaticState" %} finds non-private static fields
|
2021-05-25 19:18:28 +02:00
|
|
|
that are not final. These fields break encapsulation since these fields can be modified from anywhere
|
|
|
|
within the program. You can try out this rule like so:
|
|
|
|
```xml
|
|
|
|
<rule ref="category/java/design.xml/MutableStaticState" />
|
|
|
|
```
|
|
|
|
|
2021-05-08 18:53:48 +02:00
|
|
|
#### Modified rules
|
|
|
|
|
|
|
|
* The Java rule {% rule "java/errorprone/CompareObjectsWithEquals" %} has now a new property
|
|
|
|
`typesThatCompareByReference`. With that property, you can configure types, that should be whitelisted
|
|
|
|
for comparison by reference. By default, `java.lang.Enum` and `java.lang.Class` are allowed, but
|
|
|
|
you could add custom types here.
|
|
|
|
Additionally comparisons against constants are allowed now. This makes the rule less noisy when two constants
|
|
|
|
are compared. Constants are identified by looking for an all-caps identifier.
|
|
|
|
|
2021-05-21 10:12:43 +02:00
|
|
|
#### Deprecated rules
|
|
|
|
|
2021-05-21 10:46:55 +02:00
|
|
|
* The java rule {% rule "java/codestyle/DefaultPackage" %} has been deprecated in favor of
|
|
|
|
{% rule "java/codestyle/CommentDefaultAccessModifier" %}.
|
2021-05-25 12:43:25 +02:00
|
|
|
|
2021-05-21 10:46:55 +02:00
|
|
|
The rule "DefaultPackage" assumes that any usage of package-access is accidental,
|
|
|
|
and by doing so, prohibits using a really fundamental and useful feature of the language.
|
2021-05-25 12:43:25 +02:00
|
|
|
|
2021-05-21 10:46:55 +02:00
|
|
|
To satisfy the rule, you have to make the member public even if it doesn't need to, or make it protected,
|
|
|
|
which muddies your intent even more if you don't intend the class to be extended, and may be at odds with
|
|
|
|
other rules like {% rule "java/codestyle/AvoidProtectedFieldInFinalClass" %}.
|
2021-05-25 12:43:25 +02:00
|
|
|
|
2021-05-21 10:46:55 +02:00
|
|
|
The rule {% rule "java/codestyle/CommentDefaultAccessModifier" %} should be used instead.
|
|
|
|
It flags the same thing, but has an escape hatch.
|
|
|
|
|
2021-05-21 10:12:43 +02:00
|
|
|
* The Java rule {% rule "java/errorprone/CloneThrowsCloneNotSupportedException" %} has been deprecated without
|
|
|
|
replacement.
|
2021-05-25 12:43:25 +02:00
|
|
|
|
2021-05-21 10:12:43 +02:00
|
|
|
The rule has no real value as `CloneNotSupportedException` is a
|
|
|
|
checked exception and therefore you need to deal with it while implementing the `clone()` method. You either
|
|
|
|
need to declare the exception or catch it. If you catch it, then subclasses can't throw it themselves explicitly.
|
|
|
|
However, `Object.clone()` will still throw this exception if the `Cloneable` interface is not implemented.
|
2021-05-25 12:43:25 +02:00
|
|
|
|
2021-05-21 10:12:43 +02:00
|
|
|
Note, this rule has also been removed from the Quickstart Ruleset (`rulesets/java/quickstart.xml`).
|
|
|
|
|
2016-12-13 13:38:59 -03:00
|
|
|
### Fixed Issues
|
2018-09-05 01:16:04 -03:00
|
|
|
|
2021-04-29 17:04:48 +02:00
|
|
|
* apex
|
2021-05-20 13:39:51 +02:00
|
|
|
* [#3183](https://github.com/pmd/pmd/issues/3183): \[apex] ApexUnitTestMethodShouldHaveIsTestAnnotation false positive with helper method
|
2021-04-29 17:04:48 +02:00
|
|
|
* [#3243](https://github.com/pmd/pmd/pull/3243): \[apex] Correct findBoundary when traversing AST
|
2021-05-14 18:50:08 +02:00
|
|
|
* core
|
|
|
|
* [#2639](https://github.com/pmd/pmd/issues/2639): \[core] PMD CLI output file is not created if directory or directories in path don't exist
|
2021-05-27 10:23:54 +02:00
|
|
|
* [#3196](https://github.com/pmd/pmd/issues/3196): \[core] Deprecate ThreadSafeReportListener
|
2021-04-29 10:02:57 +02:00
|
|
|
* doc
|
|
|
|
* [#3230](https://github.com/pmd/pmd/issues/3230): \[doc] Remove "Edit me" button for language index pages
|
2021-05-06 13:56:18 +02:00
|
|
|
* dist
|
|
|
|
* [#2466](https://github.com/pmd/pmd/issues/2466): \[dist] Distribution archive doesn't include all batch scripts
|
2021-05-07 16:33:49 +02:00
|
|
|
* java
|
|
|
|
* [#3269](https://github.com/pmd/pmd/pull/3269): \[java] Fix NPE in MethodTypeResolution
|
2021-05-06 13:49:14 +02:00
|
|
|
* java-bestpractices
|
2021-05-06 14:57:30 +02:00
|
|
|
* [#1175](https://github.com/pmd/pmd/issues/1175): \[java] UnusedPrivateMethod FP with Junit 5 @MethodSource
|
2021-05-13 15:19:31 +02:00
|
|
|
* [#2219](https://github.com/pmd/pmd/issues/2219): \[java] Document Reasons to Avoid Reassigning Parameters
|
2021-05-06 14:07:20 +02:00
|
|
|
* [#2737](https://github.com/pmd/pmd/issues/2737): \[java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch
|
2021-05-06 13:49:14 +02:00
|
|
|
* [#3236](https://github.com/pmd/pmd/issues/3236): \[java] LiteralsFirstInComparisons should consider constant fields (cont'd)
|
2021-05-25 19:21:29 +02:00
|
|
|
* [#3239](https://github.com/pmd/pmd/issues/3239): \[java] PMD could enforce non-public methods for Junit5 / Jupiter test methods
|
2021-05-06 11:08:43 +02:00
|
|
|
* [#3254](https://github.com/pmd/pmd/issues/3254): \[java] AvoidReassigningParameters reports violations on wrong line numbers
|
2021-04-29 11:25:56 +02:00
|
|
|
* java-codestyle
|
|
|
|
* [#2655](https://github.com/pmd/pmd/issues/2655): \[java] UnnecessaryImport false positive for on-demand imports
|
2021-05-21 10:46:55 +02:00
|
|
|
* [#3206](https://github.com/pmd/pmd/issues/3206): \[java] Deprecate rule DefaultPackage
|
2021-05-06 14:56:06 +02:00
|
|
|
* [#3262](https://github.com/pmd/pmd/pull/3262): \[java] FieldDeclarationsShouldBeAtStartOfClass: false negative with anon classes
|
2021-05-06 15:38:55 +02:00
|
|
|
* [#3265](https://github.com/pmd/pmd/pull/3265): \[java] MethodArgumentCouldBeFinal: false negatives with interfaces and inner classes
|
2021-05-06 15:49:29 +02:00
|
|
|
* [#3266](https://github.com/pmd/pmd/pull/3266): \[java] LocalVariableCouldBeFinal: false negatives with interfaces, anon classes
|
2021-05-13 18:56:20 +02:00
|
|
|
* [#3274](https://github.com/pmd/pmd/pull/3274): \[java] OnlyOneReturn: false negative with anonymous class
|
2021-05-13 19:24:17 +02:00
|
|
|
* [#3275](https://github.com/pmd/pmd/pull/3275): \[java] UnnecessaryLocalBeforeReturn: false negatives with lambda and anon class
|
2021-05-06 15:01:31 +02:00
|
|
|
* java-design
|
|
|
|
* [#2780](https://github.com/pmd/pmd/issues/2780): \[java] DataClass example from documentation results in false-negative
|
2021-05-25 19:18:28 +02:00
|
|
|
* [#2987](https://github.com/pmd/pmd/issues/2987): \[java] New Rule: Public and protected static fields must be final
|
2021-05-28 12:50:31 +02:00
|
|
|
* [#2329](https://github.com/pmd/pmd/issues/2329): \[java] Cognitive complexity rule for Java
|
2021-05-08 18:53:48 +02:00
|
|
|
* java-errorprone
|
|
|
|
* [#3110](https://github.com/pmd/pmd/issues/3110): \[java] Enhance CompareObjectsWithEquals with list of exceptions
|
2021-05-21 10:12:43 +02:00
|
|
|
* [#3112](https://github.com/pmd/pmd/issues/3112): \[java] Deprecate rule CloneThrowsCloneNotSupportedException
|
2021-05-08 18:53:48 +02:00
|
|
|
* [#3205](https://github.com/pmd/pmd/issues/3205): \[java] Make CompareObjectWithEquals allow comparing against constants
|
2021-05-14 16:46:54 +02:00
|
|
|
* [#3248](https://github.com/pmd/pmd/issues/3248): \[java] Documentation is wrong for SingletonClassReturningNewInstance rule
|
2021-05-04 19:58:33 +02:00
|
|
|
* [#3249](https://github.com/pmd/pmd/pull/3249): \[java] AvoidFieldNameMatchingTypeName: False negative with interfaces
|
2021-05-14 16:46:54 +02:00
|
|
|
* [#3268](https://github.com/pmd/pmd/pull/3268): \[java] ConstructorCallsOverridableMethod: IndexOutOfBoundsException with annotations
|
2021-05-14 11:40:11 +02:00
|
|
|
* java-performance
|
|
|
|
* [#1438](https://github.com/pmd/pmd/issues/1438): \[java] InsufficientStringBufferDeclaration false positive for initial calculated StringBuilder size
|
2021-05-21 11:03:22 +02:00
|
|
|
* javascript
|
2021-04-29 14:59:13 +02:00
|
|
|
* [#699](https://github.com/pmd/pmd/issues/699): \[javascript] Update Rhino library to 1.7.13
|
|
|
|
* [#2081](https://github.com/pmd/pmd/issues/2081): \[javascript] Failing with OutOfMemoryError parsing a Javascript file
|
2021-04-29 11:25:56 +02:00
|
|
|
|
2021-03-27 16:26:41 +01:00
|
|
|
### API Changes
|
2021-03-01 20:13:37 +01:00
|
|
|
|
2021-05-27 10:23:54 +02:00
|
|
|
#### Deprecated API
|
|
|
|
|
2021-05-27 10:43:02 +02:00
|
|
|
* {% jdoc !!core::PMD#doPMD(net.sourceforge.pmd.PMDConfiguration) %} is deprecated.
|
|
|
|
Use {% jdoc !!core::PMD#runPMD(net.sourceforge.pmd.PMDConfiguration) %} instead.
|
|
|
|
* {% jdoc !!core::PMD#run(java.lang.String[]) %} is deprecated.
|
|
|
|
Use {% jdoc !!core::PMD#runPMD(java.lang.String...) %} instead.
|
2021-05-27 10:23:54 +02:00
|
|
|
* {% jdoc core::ThreadSafeReportListener %} and the methods to use them in {% jdoc core::Report %}
|
2021-05-27 10:43:02 +02:00
|
|
|
({% jdoc core::Report#addListener(net.sourceforge.pmd.ThreadSafeReportListener) %},
|
|
|
|
{% jdoc core::Report#getListeners() %}, {% jdoc core::Report#addListeners(java.util.List) %})
|
|
|
|
are deprecated. This functionality will be replaced by another TBD mechanism in PMD 7.
|
2021-05-27 10:23:54 +02:00
|
|
|
|
2017-12-20 23:24:37 -03:00
|
|
|
### External Contributions
|
2021-05-20 13:39:51 +02:00
|
|
|
* [#3272](https://github.com/pmd/pmd/pull/3272): \[apex] correction for ApexUnitTestMethodShouldHaveIsTestAnnotation false positives - [William Brockhus](https://github.com/YodaDaCoda)
|
2021-05-25 19:18:28 +02:00
|
|
|
* [#3246](https://github.com/pmd/pmd/pull/3246): \[java] New Rule: MutableStaticState - [Vsevolod Zholobov](https://github.com/vszholobov)
|
2021-05-25 19:21:29 +02:00
|
|
|
* [#3247](https://github.com/pmd/pmd/pull/3247): \[java] New rule: JUnit5TestShouldBePackagePrivate - [Arnaud Jeansen](https://github.com/ajeans)
|
2021-05-28 12:48:40 +02:00
|
|
|
* [#3293](https://github.com/pmd/pmd/pull/3293): \[java] Cognitive Complexity Metric - [Denis Borovikov](https://github.com/borovikovd)
|
2021-05-27 11:04:08 +02:00
|
|
|
* [pmd.github.io#12](https://github.com/pmd/pmd.github.io/pull/12): Update quickstart.html - [Igor Lyadov](https://github.com/devigo)
|
2020-07-25 13:36:28 +02:00
|
|
|
|
2018-08-18 16:44:45 +02:00
|
|
|
{% endtocmaker %}
|