Skip to content

Commit b599e12

Browse files
committed
Fixing Findbugs warnings and adding a bold WARNING to GnuParser that there is a large lump of non-executable code
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/branches/cli-1.0.x@542151 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1b29e86 commit b599e12

4 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/java/org/apache/commons/cli/GnuParser.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ else if (stopAtNonOption)
106106
}
107107
else
108108
{
109+
// WARNING: Findbugs reports major problems with the following code.
110+
// As option cannot be null, currentOption cannot and
111+
// much of the code below is never going to be run.
112+
109113
currentOption = option;
110114

111115
// special option
@@ -169,6 +173,6 @@ else if (stopAtNonOption)
169173
}
170174
}
171175

172-
return (String[]) tokens.toArray(new String[] { });
176+
return (String[]) tokens.toArray(new String[tokens.size()]);
173177
}
174-
}
178+
}

src/java/org/apache/commons/cli/Option.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ public String getValue(String defaultValue)
541541
public String[] getValues()
542542
{
543543
return hasNoValues()
544-
? null : (String[]) this.values.toArray(new String[] { });
544+
? null : (String[]) this.values.toArray(new String[this.values.size()]);
545545
}
546546

547547
/**

src/java/org/apache/commons/cli/PosixParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ else if (options.hasOption(token)) {
160160
gobble(iter);
161161
}
162162

163-
return (String[]) tokens.toArray(new String[] { });
163+
return (String[]) tokens.toArray(new String[tokens.size()]);
164164
}
165165

166166
/**
@@ -308,4 +308,4 @@ else if (stopAtNonOption)
308308
}
309309
}
310310
}
311-
}
311+
}

src/java/org/apache/commons/cli/TypeHandler.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,7 @@ public static Class createClass(String str)
208208
*/
209209
public static Date createDate(String str)
210210
{
211-
Date date = null;
212-
213-
if (date == null)
214-
{
215-
System.err.println("Unable to parse: " + str);
216-
}
217-
218-
return date;
211+
throw new UnsupportedOperationException("Not yet implemented");
219212
}
220213

221214
/**

0 commit comments

Comments
 (0)