UnusedPrivateMethod false positive for array element method call
A source code analyzer
Brought to you by:
adangel,
juansotuyo
A method is incorrectly flagged as unused when only called with an array element method return. The workaround is to get the element then call the method.
Example
public void doSomething() { File[] files = getFiles(); for (int i = 0; i < files.length; i++) { String name = getNameFromFilename(files[i].getName()); System.out.println("name is " + name); } } private String getNameFromFilename(String fileName) { int index = fileName.lastIndexOf('.'); return fileName.substring(0, index); }
This will be fixed with PMD 5.3.4.
Commit: https://github.com/pmd/pmd/commit/1984f5ac8add597055fcfcea6eabbd4a1493376f
Diff: