Skip to content

Commit

Permalink
Merge branch 'pr-4937'
Browse files Browse the repository at this point in the history
  • Loading branch information
jsotuyod committed Apr 7, 2024
2 parents c81be9d + 2c26e43 commit d4b99bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/pages/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ This is a {{ site.pmd.release_type }} release.
* java-codestyle
* [#4602](https://github.com/pmd/pmd/issues/4602): \[java] UnnecessaryImport: false positives with static imports
* [#4785](https://github.com/pmd/pmd/issues/4785): \[java] False Positive: PMD Incorrectly report violation for UnnecessaryImport
* [#4779](https://github.com/pmd/pmd/issues/4779): \[java] Examples in documentation of MethodArgumentCanBeFinal do not trigger the rule
* [#4881](https://github.com/pmd/pmd/issues/4881): \[java] ClassNamingConventions: interfaces are identified as abstract classes (regression in 7.0.0)
* java-design
* [#3694](https://github.com/pmd/pmd/issues/3694): \[java] SingularField ignores static variables
Expand Down
24 changes: 17 additions & 7 deletions pmd-java/src/main/resources/category/java/codestyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1034,17 +1034,27 @@ public class MissingTheProperSuffix implements SessionBean {} // non-standard
class="net.sourceforge.pmd.lang.java.rule.codestyle.MethodArgumentCouldBeFinalRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#methodargumentcouldbefinal">
<description>
A method argument that is never re-assigned within the method can be declared final.
Reports method and constructor parameters that can be made final because they are never reassigned within the body of the method.

This rule ignores unused parameters so as not to overlap with the rule {% rule 'java/bestpractices/UnusedFormalParameter' %}.
It will also ignore the parameters of abstract methods.
</description>
<priority>3</priority>
<example>
<![CDATA[
public void foo1 (String param) { // do stuff with param never assigning it
}
public void foo2 (final String param) { // better, do stuff with param never assigning it
class Foo {
// reported, parameter can be declared final
public String foo1(String param) {
return param;
}
// not reported, parameter is declared final
public String foo2(final String param) {
return param.trim();
}
// not reported because param is unused
public String unusedParam(String param) {
return "abc";
}
}
]]>
</example>
Expand Down

0 comments on commit d4b99bb

Please sign in to comment.