Affects PMD Version: tbd
Rule: MethodReturnsInternalArray, https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#methodreturnsinternalarray
Description: Static final fields are currently ignored as per https://sourceforge.net/p/pmd/bugs/1475/. However, this is only safe because the array has length zero. Sharing non-empty arrays is problematic whether the field is final or not, so it doesn't make sense to forbid one and allow the other.
Code Sample demonstrating the issue:
public class MyClass { private static final String[] FOO_BAR = new String[] { "foo", "bar" }; public String[] call() { return FOO_BAR; } }
Second example:
public class MyClass { private String[] fooBar = new String[0]; public String[] call() { return fooBar; } }
Expected outcome: A violation should be reported on the first example
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