Skip to content

Commit bc0edc4

Browse files
committed
Clean ups.
- maven-checkstyle-plugin 3.1.1 -> 3.1.2. - checkstyle -> 9.0 - Updates for 21st century. - No need to nest else clause. - Use simple array declarations. - Use valueOf instead of new for Numbers. - Consistent formatting. - Remove some inline comments //-----...
1 parent 2b026b2 commit bc0edc4

53 files changed

Lines changed: 2680 additions & 3864 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 72 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@
9696
<id>chtompki</id>
9797
<email>chtompki@apache.org</email>
9898
</developer>
99+
<developer>
100+
<id>ggregory</id>
101+
<name>Gary Gregory</name>
102+
<email>ggregory at apache.org</email>
103+
<url>https://www.garygregory.com</url>
104+
<organization>The Apache Software Foundation</organization>
105+
<organizationUrl>https://www.apache.org/</organizationUrl>
106+
<roles>
107+
<role>PMC Member</role>
108+
</roles>
109+
<timezone>America/New_York</timezone>
110+
<properties>
111+
<picUrl>https://people.apache.org/~ggregory/img/garydgregory80.png</picUrl>
112+
</properties>
113+
</developer>
99114
</developers>
100115

101116
<contributors>
@@ -187,59 +202,17 @@
187202
<commons.jira.pid>12310463</commons.jira.pid>
188203
<!-- The RC version used in the staging repository URL. -->
189204
<commons.rc.version>RC1</commons.rc.version>
190-
191205
<commons.scmPubUrl>https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-cli</commons.scmPubUrl>
192206
<commons.scmPubCheckoutDirectory>site-content</commons.scmPubCheckoutDirectory>
193207
<commons.encoding>utf-8</commons.encoding>
208+
<commons.checkstyle-plugin.version>3.1.2</commons.checkstyle-plugin.version>
209+
<commons.checkstyle.impl.version>9.0</commons.checkstyle.impl.version>
194210
</properties>
195211

196212
<build>
197213
<defaultGoal>clean package apache-rat:check clirr:check checkstyle:check findbugs:check javadoc:javadoc</defaultGoal>
198-
<plugins>
199-
<plugin>
200-
<artifactId>maven-assembly-plugin</artifactId>
201-
<configuration>
202-
<descriptors>
203-
<descriptor>src/assembly/bin.xml</descriptor>
204-
<descriptor>src/assembly/src.xml</descriptor>
205-
</descriptors>
206-
<tarLongFileMode>gnu</tarLongFileMode>
207-
</configuration>
208-
</plugin>
209-
<!--
210-
Fix for https://bugs.openjdk.java.net/browse/JDK-8212233
211-
which is addressed in maven-javadoc-plugin:3.1.0, see https://issues.apache.org/jira/browse/MJAVADOC-562
212-
-->
213-
<plugin>
214-
<groupId>org.apache.maven.plugins</groupId>
215-
<artifactId>maven-javadoc-plugin</artifactId>
216-
<version>${commons.javadoc.version}</version>
217-
<configuration>
218-
<source>7</source>
219-
</configuration>
220-
</plugin>
221-
</plugins>
222214
<pluginManagement>
223215
<plugins>
224-
<plugin>
225-
<groupId>org.apache.maven.plugins</groupId>
226-
<artifactId>maven-scm-publish-plugin</artifactId>
227-
<configuration>
228-
<ignorePathsToDelete>
229-
<ignorePathToDelete>javadocs**</ignorePathToDelete>
230-
</ignorePathsToDelete>
231-
</configuration>
232-
</plugin>
233-
<plugin>
234-
<groupId>org.apache.maven.plugins</groupId>
235-
<artifactId>maven-checkstyle-plugin</artifactId>
236-
<version>${commons.checkstyle-plugin.version}</version>
237-
<configuration>
238-
<configLocation>${basedir}/src/conf/checkstyle.xml</configLocation>
239-
<enableRulesSummary>false</enableRulesSummary>
240-
<suppressionsLocation>${basedir}/src/conf/checkstyle-suppressions.xml</suppressionsLocation>
241-
</configuration>
242-
</plugin>
243216
<plugin>
244217
<groupId>org.apache.rat</groupId>
245218
<artifactId>apache-rat-plugin</artifactId>
@@ -251,6 +224,24 @@
251224
</excludes>
252225
</configuration>
253226
</plugin>
227+
<plugin>
228+
<groupId>org.apache.maven.plugins</groupId>
229+
<artifactId>maven-checkstyle-plugin</artifactId>
230+
<version>${commons.checkstyle-plugin.version}</version>
231+
<configuration>
232+
<configLocation>${basedir}/src/conf/checkstyle.xml</configLocation>
233+
<suppressionsLocation>${basedir}/src/conf/checkstyle-suppressions.xml</suppressionsLocation>
234+
<enableRulesSummary>false</enableRulesSummary>
235+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
236+
</configuration>
237+
<dependencies>
238+
<dependency>
239+
<groupId>com.puppycrawl.tools</groupId>
240+
<artifactId>checkstyle</artifactId>
241+
<version>${commons.checkstyle.impl.version}</version>
242+
</dependency>
243+
</dependencies>
244+
</plugin>
254245
<plugin>
255246
<groupId>org.codehaus.mojo</groupId>
256247
<artifactId>findbugs-maven-plugin</artifactId>
@@ -261,8 +252,45 @@
261252
<excludeFilterFile>${basedir}/src/conf/findbugs-exclude-filter.xml</excludeFilterFile>
262253
</configuration>
263254
</plugin>
255+
<plugin>
256+
<groupId>org.apache.maven.plugins</groupId>
257+
<artifactId>maven-scm-publish-plugin</artifactId>
258+
<configuration>
259+
<ignorePathsToDelete>
260+
<ignorePathToDelete>javadocs**</ignorePathToDelete>
261+
</ignorePathsToDelete>
262+
</configuration>
263+
</plugin>
264264
</plugins>
265265
</pluginManagement>
266+
<plugins>
267+
<plugin>
268+
<groupId>org.apache.maven.plugins</groupId>
269+
<artifactId>maven-checkstyle-plugin</artifactId>
270+
</plugin>
271+
<plugin>
272+
<artifactId>maven-assembly-plugin</artifactId>
273+
<configuration>
274+
<descriptors>
275+
<descriptor>src/assembly/bin.xml</descriptor>
276+
<descriptor>src/assembly/src.xml</descriptor>
277+
</descriptors>
278+
<tarLongFileMode>gnu</tarLongFileMode>
279+
</configuration>
280+
</plugin>
281+
<!--
282+
Fix for https://bugs.openjdk.java.net/browse/JDK-8212233
283+
which is addressed in maven-javadoc-plugin:3.1.0, see https://issues.apache.org/jira/browse/MJAVADOC-562
284+
-->
285+
<plugin>
286+
<groupId>org.apache.maven.plugins</groupId>
287+
<artifactId>maven-javadoc-plugin</artifactId>
288+
<version>${commons.javadoc.version}</version>
289+
<configuration>
290+
<source>7</source>
291+
</configuration>
292+
</plugin>
293+
</plugins>
266294
</build>
267295

268296
<reporting>
@@ -280,19 +308,6 @@
280308
<plugin>
281309
<groupId>org.apache.maven.plugins</groupId>
282310
<artifactId>maven-checkstyle-plugin</artifactId>
283-
<version>${commons.checkstyle-plugin.version}</version>
284-
<configuration>
285-
<configLocation>${basedir}/src/conf/checkstyle.xml</configLocation>
286-
<enableRulesSummary>false</enableRulesSummary>
287-
<suppressionsLocation>${basedir}/src/conf/checkstyle-suppressions.xml</suppressionsLocation>
288-
</configuration>
289-
<reportSets>
290-
<reportSet>
291-
<reports>
292-
<report>checkstyle</report>
293-
</reports>
294-
</reportSet>
295-
</reportSets>
296311
</plugin>
297312
<plugin>
298313
<groupId>org.apache.rat</groupId>

src/conf/checkstyle-suppressions.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0"?>
2-
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN" "https://checkstyle.org/dtds/suppressions_1_0.dtd">
2+
<!DOCTYPE suppressions PUBLIC
3+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
4+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
35
<!--
46
Licensed to the Apache Software Foundation (ASF) under one or more
57
contributor license agreements. See the NOTICE file distributed with
@@ -19,6 +21,15 @@
1921

2022
<suppressions>
2123

24+
<!-- Suppress some test checks-->
25+
<suppress checks="JavadocMethod" files="src[/\\]test[/\\]java[/\\]" />
26+
<suppress checks="JavadocPackage" files="src[/\\]test[/\\]java[/\\]" />
27+
<suppress checks="JavadocVariable" files="src[/\\]test[/\\]java[/\\]" />
28+
<suppress checks="MethodName" files="src[/\\]test[/\\]java[/\\]" />
29+
<suppress checks="MagicNumber" files="src[/\\]test[/\\]java[/\\]" />
30+
<suppress checks="ParameterNumber" files="src[/\\]test[/\\]java[/\\]" />
31+
<suppress checks="MethodLength" files="BugCLI162Test.java" />
32+
2233
<!-- Suppress visibility check of some member fields as they have to be kept
2334
for binary compatibility reasons -->
2435
<suppress checks="VisibilityModifier" files="HelpFormatter.java" />

src/conf/checkstyle.xml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ limitations under the License.
2424

2525
<module name="Checker">
2626
<property name="localeLanguage" value="en"/>
27-
<property name="severity" value="warning"/>
2827

2928
<!-- Checks that a package.html file exists for each package. -->
3029
<!-- See http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage -->
@@ -38,26 +37,18 @@ limitations under the License.
3837
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
3938
<module name="Translation"/>
4039

41-
<!-- Exceptions -->
42-
<module name="SuppressionFilter">
43-
<property name="file" value="${checkstyle.suppressions.file}"/>
44-
</module>
45-
4640
<module name="FileTabCharacter">
4741
<property name="eachLine" value="true"/>
4842
</module>
4943

5044
<module name="LineLength">
51-
<property name="max" value="120"/>
45+
<property name="max" value="160"/>
5246
</module>
5347

5448
<module name="TreeWalker">
5549

5650
<!-- Checks for Javadoc comments. -->
5751
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
58-
<module name="JavadocMethod">
59-
<property name="scope" value="public"/>
60-
</module>
6152
<module name="JavadocType"/>
6253
<module name="JavadocVariable"/>
6354

@@ -90,13 +81,11 @@ limitations under the License.
9081
<property name="max" value="9"/>
9182
</module>
9283

93-
9484
<!-- Checks for whitespace -->
9585
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
9686
<module name="EmptyForIteratorPad"/>
9787
<module name="NoWhitespaceAfter"/>
9888
<module name="NoWhitespaceBefore"/>
99-
<module name="OperatorWrap"/>
10089
<module name="ParenPad"/>
10190

10291
<module name="WhitespaceAfter"/>
@@ -115,13 +104,7 @@ limitations under the License.
115104
<module name="EmptyBlock">
116105
<property name="option" value="text"/>
117106
</module>
118-
<module name="LeftCurly">
119-
<property name="option" value="nl"/>
120-
</module>
121107
<module name="NeedBraces"/>
122-
<module name="RightCurly">
123-
<property name="option" value="alone"/>
124-
</module>
125108

126109
<!-- Checks for common coding problems -->
127110
<!-- See http://checkstyle.sf.net/config_coding.html -->

src/main/java/org/apache/commons/cli/AlreadySelectedException.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ Licensed to the Apache Software Foundation (ASF) under one or more
1818
package org.apache.commons.cli;
1919

2020
/**
21-
* Thrown when more than one option in an option group
22-
* has been provided.
21+
* Thrown when more than one option in an option group has been provided.
2322
*/
24-
public class AlreadySelectedException extends ParseException
25-
{
23+
public class AlreadySelectedException extends ParseException {
2624
/**
2725
* This exception {@code serialVersionUID}.
2826
*/
@@ -35,28 +33,23 @@ public class AlreadySelectedException extends ParseException
3533
private Option option;
3634

3735
/**
38-
* Construct a new <code>AlreadySelectedException</code>
39-
* with the specified detail message.
36+
* Construct a new <code>AlreadySelectedException</code> with the specified detail message.
4037
*
4138
* @param message the detail message
4239
*/
43-
public AlreadySelectedException(final String message)
44-
{
40+
public AlreadySelectedException(final String message) {
4541
super(message);
4642
}
4743

4844
/**
49-
* Construct a new <code>AlreadySelectedException</code>
50-
* for the specified option group.
45+
* Construct a new <code>AlreadySelectedException</code> for the specified option group.
5146
*
52-
* @param group the option group already selected
47+
* @param group the option group already selected
5348
* @param option the option that triggered the exception
5449
* @since 1.2
5550
*/
56-
public AlreadySelectedException(final OptionGroup group, final Option option)
57-
{
58-
this("The option '" + option.getKey() + "' was specified but an option from this group "
59-
+ "has already been selected: '" + group.getSelected() + "'");
51+
public AlreadySelectedException(final OptionGroup group, final Option option) {
52+
this("The option '" + option.getKey() + "' was specified but an option from this group " + "has already been selected: '" + group.getSelected() + "'");
6053
this.group = group;
6154
this.option = option;
6255
}
@@ -67,8 +60,7 @@ public AlreadySelectedException(final OptionGroup group, final Option option)
6760
* @return the related option group
6861
* @since 1.2
6962
*/
70-
public OptionGroup getOptionGroup()
71-
{
63+
public OptionGroup getOptionGroup() {
7264
return group;
7365
}
7466

@@ -78,8 +70,7 @@ public OptionGroup getOptionGroup()
7870
* @return the related option
7971
* @since 1.2
8072
*/
81-
public Option getOption()
82-
{
73+
public Option getOption() {
8374
return option;
8475
}
8576
}

src/main/java/org/apache/commons/cli/AmbiguousOptionException.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2525
*
2626
* @since 1.3
2727
*/
28-
public class AmbiguousOptionException extends UnrecognizedOptionException
29-
{
28+
public class AmbiguousOptionException extends UnrecognizedOptionException {
3029
/**
3130
* This exception {@code serialVersionUID}.
3231
*/
@@ -38,21 +37,20 @@ public class AmbiguousOptionException extends UnrecognizedOptionException
3837
/**
3938
* Constructs a new AmbiguousOptionException.
4039
*
41-
* @param option the partial option name
40+
* @param option the partial option name
4241
* @param matchingOptions the options matching the name
4342
*/
44-
public AmbiguousOptionException(final String option, final Collection<String> matchingOptions)
45-
{
43+
public AmbiguousOptionException(final String option, final Collection<String> matchingOptions) {
4644
super(createMessage(option, matchingOptions), option);
4745
this.matchingOptions = matchingOptions;
4846
}
4947

5048
/**
5149
* Returns the options matching the partial name.
50+
*
5251
* @return a collection of options matching the name
5352
*/
54-
public Collection<String> getMatchingOptions()
55-
{
53+
public Collection<String> getMatchingOptions() {
5654
return matchingOptions;
5755
}
5856

@@ -63,20 +61,17 @@ public Collection<String> getMatchingOptions()
6361
* @param matchingOptions
6462
* @return
6563
*/
66-
private static String createMessage(final String option, final Collection<String> matchingOptions)
67-
{
64+
private static String createMessage(final String option, final Collection<String> matchingOptions) {
6865
final StringBuilder buf = new StringBuilder("Ambiguous option: '");
6966
buf.append(option);
7067
buf.append("' (could be: ");
7168

7269
final Iterator<String> it = matchingOptions.iterator();
73-
while (it.hasNext())
74-
{
70+
while (it.hasNext()) {
7571
buf.append("'");
7672
buf.append(it.next());
7773
buf.append("'");
78-
if (it.hasNext())
79-
{
74+
if (it.hasNext()) {
8075
buf.append(", ");
8176
}
8277
}

0 commit comments

Comments
 (0)