Turn on many more Eclipse warnings, and fix them
- Warn on empty statements, e.g. "for (;;);". These may be
typos and are easily replaced by "for (;;) {}" which is more
explicit.
- Warn on field hiding. This allows cleanup of many acceptance test
members, at the cost of a couple of renames and the occasional
suppression (when the field is in a public nested enum that shadows
a public constant).
- Warn on unnecessary casts.
- Warn on unused declared thrown exceptions. In addition to reducing
method signature length and number of imports, this also eliminated
some impossible catch blocks.
- Warn on missing @Override annotations.
- Warn on unused parameters. This is likely the most controversial,
as a few relatively common patterns require unused parameters in a
way that Eclipse can't ignore. However, it also resulted in cleanup
of a lot of unnecessary injections and method parameters, so I
think the cost was worth it.
Change-Id: I7224be8b1c798613a127c88507e8cce400679e5d
This commit is contained in:
@@ -131,7 +131,7 @@ public class CmdLineParser {
|
||||
|
||||
char next = '?';
|
||||
List<NamedOptionDef> booleans = new ArrayList<>();
|
||||
for (@SuppressWarnings("rawtypes") OptionHandler handler : parser.options) {
|
||||
for (@SuppressWarnings("rawtypes") OptionHandler handler : parser.optionsList) {
|
||||
if (handler.option instanceof NamedOptionDef) {
|
||||
NamedOptionDef n = (NamedOptionDef) handler.option;
|
||||
|
||||
@@ -274,7 +274,7 @@ public class CmdLineParser {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private OptionHandler findHandler(String name) {
|
||||
if (options == null) {
|
||||
options = index(parser.options);
|
||||
options = index(parser.optionsList);
|
||||
}
|
||||
return options.get(name);
|
||||
}
|
||||
@@ -318,7 +318,7 @@ public class CmdLineParser {
|
||||
|
||||
private class MyParser extends org.kohsuke.args4j.CmdLineParser {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private List<OptionHandler> options;
|
||||
private List<OptionHandler> optionsList;
|
||||
private HelpOption help;
|
||||
|
||||
MyParser(final Object bean) {
|
||||
@@ -344,14 +344,14 @@ public class CmdLineParser {
|
||||
@SuppressWarnings("rawtypes")
|
||||
private OptionHandler add(OptionHandler handler) {
|
||||
ensureOptionsInitialized();
|
||||
options.add(handler);
|
||||
optionsList.add(handler);
|
||||
return handler;
|
||||
}
|
||||
|
||||
private void ensureOptionsInitialized() {
|
||||
if (options == null) {
|
||||
if (optionsList == null) {
|
||||
help = new HelpOption();
|
||||
options = Lists.newArrayList();
|
||||
optionsList = Lists.newArrayList();
|
||||
addOption(help, help);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user