diff --git a/pmd-core/src/main/resources/rulesets/releases/540.xml b/pmd-core/src/main/resources/rulesets/releases/540.xml index 7bace17042..ba806a578f 100644 --- a/pmd-core/src/main/resources/rulesets/releases/540.xml +++ b/pmd-core/src/main/resources/rulesets/releases/540.xml @@ -9,6 +9,7 @@ This ruleset contains links to rules that are new in PMD v5.4.0 + diff --git a/pmd-java/src/main/resources/rulesets/java/clone.xml b/pmd-java/src/main/resources/rulesets/java/clone.xml index 82dda023fa..766f713df3 100644 --- a/pmd-java/src/main/resources/rulesets/java/clone.xml +++ b/pmd-java/src/main/resources/rulesets/java/clone.xml @@ -136,7 +136,10 @@ public class MyClass { class="net.sourceforge.pmd.lang.rule.XPathRule" externalInfoUrl="${pmd.website.baseurl}/rules/java/clone.html#CloneMethodReturnTypeMustMatchClassName"> -If a class implements cloneable the return type of the method clone() must be the class name. +If a class implements cloneable the return type of the method clone() must be the class name. That way, the caller +of the clone method doesn't need to cast the returned clone to the correct type. + +Note: This is only possible with Java 1.5 or higher. 3 diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md index 2f09ae9ad5..c12f661167 100644 --- a/src/site/markdown/overview/changelog.md +++ b/src/site/markdown/overview/changelog.md @@ -9,19 +9,30 @@ * [#1344](https://sourceforge.net/p/pmd/bugs/1344/): AbstractNaming should check reverse * [#1361](https://sourceforge.net/p/pmd/bugs/1361/): ShortVariable and ShortMethodName configuration -**New/Modified/Deprecated Rules:** - +**New Rules:** * New Rule: rulesets/java/design.xml/SingleMethodSingletonRule: Verifies that there is only one method called "getInstance". If there are more methods that return the singleton, than it can easily happen, that these are not the same instances - and thus no singleton. * New Rule: rulesets/java/design.xml/SingletonClassReturningNewInstance: Verifies that the method called "getInstance" returns a cached instance not always a fresh, new instance. -* Language Java, ruleset design.xml: The rule "UseSingleton" *has been renamed* to "UseUtilityClass". - See also bugs [#1059](https://sourceforge.net/p/pmd/bugs/1059) and [#1339](https://sourceforge.net/p/pmd/bugs/1339/). * New Rule: rulesets/pom/basic.xml/ProjectVersionAsDependencyVersion: Checks the usage of ${project.version} in Maven POM files. This rule can be found in the pmd-xml module. * New Rule: rulesets/pom/basic.xml/InvalidDependencyTypes: Verifies that only the default types (jar, war, ...) for dependencies are used. This rule can be found in the pmd-xml module. +* New Rule: rulesets/java/comments.xml/CommentDefaultAccessModifier: In order to avoid mistakes with + forgotten access modifiers for methods, this rule ensures, that you explicitly mark the usage of the + default access modifier by placing a comment. +* New Rule: rulesets/java/basic.xml/SimplifiedTernary: Ternary operator with a boolean literal + can be simplified with a boolean expression. +* New Rule: rulesets/java/unnecessary.xml/UselessQualifiedThis: Flags unnecessary qualified usages + of this, when `this` alone would be unique. E.g. use just `this` instead of `Foo.this`. +* New Rule: rulesets/java/clone.xml/CloneMethodReturnTypeMustMatchClassName: If a class implements cloneable + the return type of the method clone() must be the class name. + +**Modified/Deprecated Rules:** + +* Renamed Rule: Language Java, ruleset design.xml: The rule "UseSingleton" *has been renamed* to "UseUtilityClass". + See also bugs [#1059](https://sourceforge.net/p/pmd/bugs/1059) and [#1339](https://sourceforge.net/p/pmd/bugs/1339/). * Modified Rule: rulesets/java/naming.xml/AbstractNaming: By default, this rule flags now classes, that are named "Abstract" but are not abstract. This behavior can be disabled by setting the new property "strict" to false. @@ -29,15 +40,8 @@ the minimum required length of a variable name. * Modified Rule: rulesets/java/naming.xml/ShortMethodName: Additional property `minimum` to configure the minimum required length of a method name. -* New Rule: rulesets/java/comments.xml/CommentDefaultAccessModifier: In order to avoid mistakes with - forgotten access modifiers for methods, this rule ensures, that you explicitly mark the usage of the - default access modifier by placing a comment. -* New Rule: rulesets/java/basic.xml/SimplifiedTernary: Ternary operator with a boolean literal - can be simplified with a boolean expression. * Modified Rule: rulesets/java/junit.xml/UseAssertTrueInsteadOfAssertEquals: This rule also flags assertEquals, that use Boolean.TRUE/FALSE constants. -* New Rule: rulesets/java/unnecessary.xml/UselessQualifiedThis: Flags unnecessary qualified usages - of this, when `this` alone would be unique. E.g. use just `this` instead of `Foo.this`. **Pull Requests:** @@ -50,6 +54,7 @@ * [#58](https://github.com/pmd/pmd/pull/58): Add rule for unnecessary literal boolean in ternary operators * [#59](https://github.com/pmd/pmd/pull/59): Add check to Boxed booleans in UseAssertTrueInsteadOfAssertEquals rule * [#60](https://github.com/pmd/pmd/pull/60): Add UselessQualifiedThisRule +* [#61](https://github.com/pmd/pmd/pull/61): Add CloneMethodReturnTypeMustMatchClassName rule **Bugfixes:**