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