From 37f35320b5eb0b1e1df6299f92cf43b433d47361 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 10 Apr 2021 16:55:27 +0200 Subject: [PATCH] [doc] Update release notes, refs #3190, refs #3193 --- docs/pages/release_notes.md | 12 +++++ .../main/resources/rulesets/releases/6340.xml | 13 +++++ .../resources/category/java/bestpractices.xml | 48 ++++++++++--------- .../resources/rulesets/java/quickstart.xml | 1 + 4 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 pmd-core/src/main/resources/rulesets/releases/6340.xml diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index b8f8783555..9a9c0e66fe 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -14,11 +14,23 @@ This is a {{ site.pmd.release_type }} release. ### New and noteworthy +#### New rules + +* The new Java rule {% rule "java/bestpractices/UseStandardCharsets" %} finds usages of `Charset.forName`, + where `StandardCharsets` can be used instead. + + This rule is also part of the Quickstart Ruleset (`rulesets/java/quickstart.xml`) for Java. + ### Fixed Issues +* java-bestpractices + * [#3190](https://github.com/pmd/pmd/issues/3190): \[java] Use StandardCharsets instead of Charset.forName + ### API Changes ### External Contributions +* [#3193](https://github.com/pmd/pmd/pull/3193): \[java] New rule: UseStandardCharsets - [Andrea Aime](https://github.com/aaime) + {% endtocmaker %} diff --git a/pmd-core/src/main/resources/rulesets/releases/6340.xml b/pmd-core/src/main/resources/rulesets/releases/6340.xml new file mode 100644 index 0000000000..2b6a6d29b0 --- /dev/null +++ b/pmd-core/src/main/resources/rulesets/releases/6340.xml @@ -0,0 +1,13 @@ + + + + +This ruleset contains links to rules that are new in PMD v6.34.0 + + + + + diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index d05f2a4a48..f255ecc758 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -1831,34 +1831,36 @@ public class Foo { - - + + Starting with Java 7, StandardCharsets provides constants for common Charset objects, such as UTF-8. Using the constants is less error prone, and can provide a small performance advantage compared to `Charset.forName(...)` since no scan across the internal `Charset` caches is needed. - - 3 - - - - + + 3 + + + + - - - - + + + + - - + + - +