A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/3630 below:

[java] MethodReturnsInternalArray doesn't consider anonymous classes · Issue #3630 · pmd/pmd · GitHub

Affects PMD Version: 6.40.0

Rule: MethodReturnsInternalArray

Description:

Methods in anonymous classes are not considered.

Code Sample demonstrating the issue:

public class Outer {
    private static final String[] names = new String[] {"a", "b"};
    public static Provider getProvider() {
        return new Provider() {
            @Override
            public String[] getNames() {
                return names; // expected a violation here
            }
        };
    }
    public interface Provider {
        String[] getNames();
    }
}

Expected outcome:

PMD should report a violation at line 7, but doesn't. This is a false-negative.

Note: already fixed by #3619


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