-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava-unusedcode.xml
More file actions
125 lines (116 loc) · 4.05 KB
/
java-unusedcode.xml
File metadata and controls
125 lines (116 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?xml version="1.0"?>
<ruleset name="Unused Code"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
The Unused Code ruleset contains rules that find unused or ineffective code.
</description>
<rule name="UnusedPrivateField"
since="0.1"
language="java"
message="Avoid unused private fields such as ''{0}''."
class="net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedPrivateFieldRule"
externalInfoUrl="https://pmd.github.io/pmd-5.5.1/pmd-java/rules/java/unusedcode.html#UnusedPrivateField">
<description>
Detects when a private field is declared and/or assigned a value, but not used.
</description>
<priority>3</priority>
<example>
<![CDATA[
public class Something {
private static int FOO = 2; // Unused
private int i = 5; // Unused
private int j = 6;
public int addOne() {
return j++;
}
}
]]>
</example>
</rule>
<rule name="UnusedLocalVariable"
language="java"
since="0.1"
message="Avoid unused local variables such as ''{0}''."
class="net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedLocalVariableRule"
externalInfoUrl="https://pmd.github.io/pmd-5.5.1/pmd-java/rules/java/unusedcode.html#UnusedLocalVariable">
<description>
Detects when a local variable is declared and/or assigned, but not used.
</description>
<priority>3</priority>
<example>
<![CDATA[
public class Foo {
public void doSomething() {
int i = 5; // Unused
}
}
]]>
</example>
</rule>
<rule name="UnusedPrivateMethod"
language="java"
since="0.7"
message="Avoid unused private methods such as ''{0}''."
class="net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedPrivateMethodRule"
externalInfoUrl="https://pmd.github.io/pmd-5.5.1/pmd-java/rules/java/unusedcode.html#UnusedPrivateMethod">
<description>
Unused Private Method detects when a private method is declared but is unused.
</description>
<priority>3</priority>
<example>
<![CDATA[
public class Something {
private void foo() {} // unused
}
]]>
</example>
</rule>
<rule name="UnusedFormalParameter"
language="java"
since="0.8"
message="Avoid unused {0} parameters such as ''{1}''."
class="net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedFormalParameterRule"
externalInfoUrl="https://pmd.github.io/pmd-5.5.1/pmd-java/rules/java/unusedcode.html#UnusedFormalParameter">
<description>
Avoid passing parameters to methods or constructors without actually referencing them in the method body.
</description>
<priority>3</priority>
<example>
<![CDATA[
public class Foo {
private void bar(String howdy) {
// howdy is not used
}
}
]]>
</example>
</rule>
<rule name="UnusedModifier"
language="java"
since="1.02"
message="Avoid modifiers which are implied by the context"
class="net.sourceforge.pmd.lang.java.rule.unusedcode.UnusedModifierRule"
externalInfoUrl="https://pmd.github.io/pmd-5.5.1/pmd-java/rules/java/unusedcode.html#UnusedModifier">
<description>
Fields in interfaces are automatically public static final, and methods are public abstract.
Classes or interfaces nested in an interface are automatically public and static (all nested interfaces are automatically static).
For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous.
</description>
<priority>3</priority>
<example>
<![CDATA[
public interface Foo {
public abstract void bar(); // both abstract and public are ignored by the compiler
public static final int X = 0; // public, static, and final all ignored
public static class Bar {} // public, static ignored
public static interface Baz {} // ditto
}
public class Bar {
public static interface Baz {} // static ignored
}
]]>
</example>
</rule>
</ruleset>