A RetroSearch Logo

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

Search Query:

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

False positive for standard UTF-8 charset name · Issue #1605 · pmd/pmd · GitHub

Affects PMD Version:

6

Rule:

LawOfDemeter

Description:

PMD's application of the Law of Demeter considers it a violation to query the standard name of the Java UTF-8 character set. Unless the character set is assigned to an explicit variable name first.

Code Sample demonstrating the issue:

public final class Fib {
    /** utility class */
    private Fib() {}

    public static void main(final String[] args) throws IOException {
        System.out.print("N = ");

        try (Scanner scanner = new Scanner(System.in, StandardCharsets.UTF_8.name())) {
            final int n = scanner.nextInt();
            System.out.println(String.format("Fib %d = %d", n, fib(n)));
        }
    }
}

As a workaround, I am disabling this rule in my rulesets.xml:

<rule ref="category/java/design.xml">
    <exclude name="LawOfDemeter" />
</rule>

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]

Gradle


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