You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/05/18 00:19:49 UTC
(commons-cli) branch master updated (cb25153 -> aef11a0)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
from cb25153 Use final
new 7cb3721 Fix PMD UnnecessaryFullyQualifiedName issues
new aef11a0 Bump commons-parent from 69 to 70
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
pom.xml | 2 +-
src/changes/changes.xml | 2 +
src/conf/spotbugs-exclude-filter.xml | 5 ++
src/main/java/org/apache/commons/cli/Option.java | 4 +-
.../java/org/apache/commons/cli/OptionBuilder.java | 58 ++++++++--------------
.../apache/commons/cli/PatternOptionBuilder.java | 19 +++----
6 files changed, 41 insertions(+), 49 deletions(-)
(commons-cli) 02/02: Bump commons-parent from 69 to 70
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
commit aef11a01e88484eed17a2975d4e1b13d323ac9ff
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 17 20:19:44 2024 -0400
Bump commons-parent from 69 to 70
Ignore odd SpotBug issue for compatibility
---
pom.xml | 2 +-
src/changes/changes.xml | 1 +
src/conf/spotbugs-exclude-filter.xml | 5 +++++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 909ed58..744b3f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
- <version>69</version>
+ <version>70</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>commons-cli</groupId>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index bb3d28f..79122ff 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -32,6 +32,7 @@
<action type="fix" dev="ggregory" due-to="Claude Warren">Cleanup deprecation issues #272.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix PMD UnnecessaryFullyQualifiedName issues.</action>
<!-- UPDATE -->
+ <action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-parent from 69 to 70.</action>
</release>
<release version="1.7.0" date="2024-04-13" description="This release contains new features and bug fixes and requires Java 8 or above.">
<!-- FIX -->
diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml
index a8b8fd3..e665f0c 100644
--- a/src/conf/spotbugs-exclude-filter.xml
+++ b/src/conf/spotbugs-exclude-filter.xml
@@ -90,6 +90,11 @@
<Method name="createDefaultPrintWriter" />
<Bug pattern="DM_DEFAULT_ENCODING" />
</Match>
+ <Match>
+ <!-- Doesn't make sense and compatibility. -->
+ <Class name="org.apache.commons.cli.TypeHandler" />
+ <Bug pattern="SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR" />
+ </Match>
<Match>
<!-- TODO ? -->
(commons-cli) 01/02: Fix PMD UnnecessaryFullyQualifiedName issues
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
commit 7cb372175182ef65ce8772103cfd015c68a430f9
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 17 20:15:29 2024 -0400
Fix PMD UnnecessaryFullyQualifiedName issues
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/commons/cli/Option.java | 4 +-
.../java/org/apache/commons/cli/OptionBuilder.java | 58 ++++++++--------------
.../apache/commons/cli/PatternOptionBuilder.java | 19 +++----
4 files changed, 34 insertions(+), 48 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b171608..bb3d28f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,6 +30,7 @@
<action type="fix" issue="CLI-331" dev="ggregory" due-to="Claude Warren, Gary Gregory">Handle reporting of deprecated options when parameters are not String type. #270.</action>
<action type="fix" dev="ggregory" due-to="Claude Warren, Gary Gregory">Avoid throwing NullPointerException when calling CommandLineParser will null array elements.</action>
<action type="fix" dev="ggregory" due-to="Claude Warren">Cleanup deprecation issues #272.</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix PMD UnnecessaryFullyQualifiedName issues.</action>
<!-- UPDATE -->
</release>
<release version="1.7.0" date="2024-04-13" description="This release contains new features and bug fixes and requires Java 8 or above.">
diff --git a/src/main/java/org/apache/commons/cli/Option.java b/src/main/java/org/apache/commons/cli/Option.java
index f9c7b5e..6df072f 100644
--- a/src/main/java/org/apache/commons/cli/Option.java
+++ b/src/main/java/org/apache/commons/cli/Option.java
@@ -199,7 +199,7 @@ public class Option implements Cloneable, Serializable {
*/
public Builder hasArg(final boolean hasArg) {
// set to UNINITIALIZED when no arg is specified to be compatible with OptionBuilder
- argCount = hasArg ? 1 : Option.UNINITIALIZED;
+ argCount = hasArg ? 1 : UNINITIALIZED;
return this;
}
@@ -209,7 +209,7 @@ public class Option implements Cloneable, Serializable {
* @return this builder.
*/
public Builder hasArgs() {
- argCount = Option.UNLIMITED_VALUES;
+ argCount = UNLIMITED_VALUES;
return this;
}
diff --git a/src/main/java/org/apache/commons/cli/OptionBuilder.java b/src/main/java/org/apache/commons/cli/OptionBuilder.java
index fda3152..c585496 100644
--- a/src/main/java/org/apache/commons/cli/OptionBuilder.java
+++ b/src/main/java/org/apache/commons/cli/OptionBuilder.java
@@ -31,7 +31,6 @@ package org.apache.commons.cli;
@Deprecated
public final class OptionBuilder {
-
/** Long option */
private static String longOption;
@@ -72,7 +71,7 @@ public final class OptionBuilder {
*/
public static Option create() throws IllegalArgumentException {
if (longOption == null) {
- OptionBuilder.reset();
+ reset();
throw new IllegalArgumentException("must specify longopt");
}
@@ -114,7 +113,7 @@ public final class OptionBuilder {
option.setArgName(argName);
} finally {
// reset the OptionBuilder properties
- OptionBuilder.reset();
+ reset();
}
// return the Option instance
@@ -127,8 +126,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder hasArg() {
- OptionBuilder.argCount = 1;
-
+ argCount = 1;
return INSTANCE;
}
@@ -139,8 +137,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder hasArg(final boolean hasArg) {
- OptionBuilder.argCount = hasArg ? 1 : Option.UNINITIALIZED;
-
+ argCount = hasArg ? 1 : Option.UNINITIALIZED;
return INSTANCE;
}
@@ -150,8 +147,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder hasArgs() {
- OptionBuilder.argCount = Option.UNLIMITED_VALUES;
-
+ argCount = Option.UNLIMITED_VALUES;
return INSTANCE;
}
@@ -162,8 +158,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder hasArgs(final int num) {
- OptionBuilder.argCount = num;
-
+ argCount = num;
return INSTANCE;
}
@@ -173,9 +168,8 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder hasOptionalArg() {
- OptionBuilder.argCount = 1;
- OptionBuilder.optionalArg = true;
-
+ argCount = 1;
+ optionalArg = true;
return INSTANCE;
}
@@ -185,9 +179,8 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder hasOptionalArgs() {
- OptionBuilder.argCount = Option.UNLIMITED_VALUES;
- OptionBuilder.optionalArg = true;
-
+ argCount = Option.UNLIMITED_VALUES;
+ optionalArg = true;
return INSTANCE;
}
@@ -198,9 +191,8 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder hasOptionalArgs(final int numArgs) {
- OptionBuilder.argCount = numArgs;
- OptionBuilder.optionalArg = true;
-
+ argCount = numArgs;
+ optionalArg = true;
return INSTANCE;
}
@@ -210,8 +202,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder isRequired() {
- OptionBuilder.required = true;
-
+ required = true;
return INSTANCE;
}
@@ -222,8 +213,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder isRequired(final boolean newRequired) {
- OptionBuilder.required = newRequired;
-
+ required = newRequired;
return INSTANCE;
}
@@ -248,8 +238,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder withArgName(final String name) {
- OptionBuilder.argName = name;
-
+ argName = name;
return INSTANCE;
}
@@ -260,8 +249,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder withDescription(final String newDescription) {
- OptionBuilder.description = newDescription;
-
+ description = newDescription;
return INSTANCE;
}
@@ -272,8 +260,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder withLongOpt(final String newLongopt) {
- OptionBuilder.longOption = newLongopt;
-
+ longOption = newLongopt;
return INSTANCE;
}
@@ -285,8 +272,7 @@ public final class OptionBuilder {
* @since 1.3
*/
public static OptionBuilder withType(final Class<?> newType) {
- OptionBuilder.type = newType;
-
+ type = newType;
return INSTANCE;
}
@@ -311,7 +297,7 @@ public final class OptionBuilder {
* <b>Example:</b>
*
* <pre>
- * Option opt = OptionBuilder.withValueSeparator().create('D');
+ * Option opt = withValueSeparator().create('D');
*
* CommandLine line = parser.parse(args);
* String propertyName = opt.getValue(0);
@@ -321,8 +307,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder withValueSeparator() {
- OptionBuilder.valueSeparator = Char.EQUAL;
-
+ valueSeparator = Char.EQUAL;
return INSTANCE;
}
@@ -345,8 +330,7 @@ public final class OptionBuilder {
* @return the OptionBuilder instance
*/
public static OptionBuilder withValueSeparator(final char sep) {
- OptionBuilder.valueSeparator = sep;
-
+ valueSeparator = sep;
return INSTANCE;
}
diff --git a/src/main/java/org/apache/commons/cli/PatternOptionBuilder.java b/src/main/java/org/apache/commons/cli/PatternOptionBuilder.java
index ff0663b..547c890 100644
--- a/src/main/java/org/apache/commons/cli/PatternOptionBuilder.java
+++ b/src/main/java/org/apache/commons/cli/PatternOptionBuilder.java
@@ -73,6 +73,7 @@ import java.util.Map;
* </p>
*/
public class PatternOptionBuilder {
+
/** String class */
public static final Class<String> STRING_VALUE = String.class;
@@ -131,23 +132,23 @@ public class PatternOptionBuilder {
public static Class<?> getValueType(final char ch) {
switch (ch) {
case '@':
- return PatternOptionBuilder.OBJECT_VALUE;
+ return OBJECT_VALUE;
case ':':
- return PatternOptionBuilder.STRING_VALUE;
+ return STRING_VALUE;
case '%':
- return PatternOptionBuilder.NUMBER_VALUE;
+ return NUMBER_VALUE;
case '+':
- return PatternOptionBuilder.CLASS_VALUE;
+ return CLASS_VALUE;
case '#':
- return PatternOptionBuilder.DATE_VALUE;
+ return DATE_VALUE;
case '<':
- return PatternOptionBuilder.EXISTING_FILE_VALUE;
+ return EXISTING_FILE_VALUE;
case '>':
- return PatternOptionBuilder.FILE_VALUE;
+ return FILE_VALUE;
case '*':
- return PatternOptionBuilder.FILES_VALUE;
+ return FILES_VALUE;
case '/':
- return PatternOptionBuilder.URL_VALUE;
+ return URL_VALUE;
}
return null;