forked from phoedos/pmd
Merge pull request #3724 from dykov:hotfix/3679
[java] Fix for #3686 - fix FinalFieldCouldBeStatic #3724 * pr-3724: [doc] Update release notes (#3679, #3724) #3679 - fix FinalFieldCouldBeStatic
This commit is contained in:
commit
7a1d787df8
@ -25,6 +25,8 @@ This is a {{ site.pmd.release_type }} release.
|
||||
* java-bestpractices
|
||||
* [#3209](https://github.com/pmd/pmd/issues/3209): \[java] UnusedPrivateMethod false positive with static method and cast expression
|
||||
* [#3468](https://github.com/pmd/pmd/issues/3468): \[java] UnusedPrivateMethod false positive when outer class calls private static method on inner class
|
||||
* java-design
|
||||
* [#3679](https://github.com/pmd/pmd/issues/3679): \[java] Make FinalFieldCouldBeStatic detect constant variable
|
||||
* java-errorprone
|
||||
* [#3686](https://github.com/pmd/pmd/issues/3686): \[java] ReturnEmptyCollectionRatherThanNull - false negative with conditioned returns
|
||||
* java-performance
|
||||
@ -41,6 +43,7 @@ This is a {{ site.pmd.release_type }} release.
|
||||
* [#3704](https://github.com/pmd/pmd/pull/3704): \[java] Fix for #3686 - Fix ReturnEmptyCollectionRatherThanNull - [Oleksii Dykov](https://github.com/dykov)
|
||||
* [#3713](https://github.com/pmd/pmd/pull/3713): \[java] Enhance UnnecessaryModifier to support records - [Vincent Galloy](https://github.com/vgalloy)
|
||||
* [#3719](https://github.com/pmd/pmd/pull/3719): \[java] Upgrade log4j to 2.17.1 - [Daniel Paul Searles](https://github.com/squaresurf)
|
||||
* [#3724](https://github.com/pmd/pmd/pull/3724): \[java] Fix for #3686 - fix FinalFieldCouldBeStatic - [Oleksii Dykov](https://github.com/dykov)
|
||||
|
||||
{% endtocmaker %}
|
||||
|
||||
|
@ -808,7 +808,9 @@ in each object at runtime.
|
||||
[not(preceding-sibling::Annotation/MarkerAnnotation/Name[@Image="Builder.Default"]
|
||||
and //ImportDeclaration/Name[@Image="lombok.Builder"])]
|
||||
/VariableDeclarator
|
||||
[VariableInitializer/Expression/PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix/Literal]
|
||||
[VariableInitializer/Expression/PrimaryExpression[not(PrimarySuffix)]
|
||||
/PrimaryPrefix/*[self::Literal or self::Name]
|
||||
]
|
||||
/VariableDeclaratorId
|
||||
]]>
|
||||
</value>
|
||||
|
@ -149,6 +149,28 @@ package com.example;
|
||||
public class ExampleClass {
|
||||
|
||||
private final String one = "one", two = "two";
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>#3679 - False-negative on initializing with another object</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>3</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
class Clazz {
|
||||
public static final int a = 10;
|
||||
public final int b = a; // should report a warning here
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>[OK] initializing with a method invocation</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
class Clazz {
|
||||
public final int a = getValue();
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Loading…
x
Reference in New Issue
Block a user