Unused Code RulesThe Unused Code Ruleset contains a collection of rules that find unused code. UnusedPrivateFieldUnused Private Field detects when a private field is declared that is not used by the class. 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++; } } UnusedLocalVariableUnused Local Variables detects when a variable is declared, but not used (except for possibly initial assignment) Here's an example of code that would trigger this rule: public int doSomething() { int i = 5; // Unused int j = 6; j += 3; return j; } UnusedPrivateMethodUnused Private Method detects when a private method is declared but is unused. Here's an example of code that would trigger this rule: public class Something { private void foo() {} // unused } UnusedFormalParameterAvoid passing parameters to methods and then not using those parameters. Here's an example of code that would trigger this rule: public class Foo { private void bar(String howdy) { // howdy is not used } |