The Unused Code Ruleset contains a collection of rules that find unused code.
Detects when a private field is declared and/or assigned a value, but not used.
This rule is defined by the following Java class: net.sourceforge.pmd.rules.UnusedPrivateFieldRule
Here's an example of code that would trigger this rule:
public class Something { private static int FOO = 2; // Unused private int i = 5; // Unused private int j = 6; public int addOne() { return j++; } }
Detects when a local variable is declared and/or assigned, but not used.
This rule is defined by the following Java class: net.sourceforge.pmd.rules.UnusedLocalVariableRule
Here's an example of code that would trigger this rule:
public void doSomething() { int i = 5; // Unused }
Unused Private Method detects when a private method is declared but is unused.
This rule is defined by the following Java class: net.sourceforge.pmd.rules.UnusedPrivateMethodRule
Here's an example of code that would trigger this rule:
public class Something { private void foo() {} // unused }
Avoid passing parameters to methods and then not using those parameters.
This rule is defined by the following Java class: net.sourceforge.pmd.rules.UnusedFormalParameterRule
Here's an example of code that would trigger this rule:
public class Foo { private void bar(String howdy) { // howdy is not used }