Affects PMD Version:
6.22.0+
7.0.0
Rule: FinalFieldCouldBeStatic
Description:
FinalFieldCouldBeStatic can not detect that the right side of the assignment is not a literal, but an expression (such as: Math.PI * 0.5).
This rule is implemented through xpath search:
<![CDATA[
//FieldDeclaration
[@Final='true' and @Static='false']
/VariableDeclarator/VariableInitializer/Expression
/PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix/Literal
]]>
Code Sample demonstrating the issue:
private final double HALF_PI = Math.PI * 0.5
Expected outcome:
false-negative
Running PMD through:
CLI
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4