Skip to content

Commit 7750297

Browse files
committed
Better Checkstyle
1 parent 403d77f commit 7750297

25 files changed

+412
-405
lines changed

pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,8 @@
463463

464464
<!--
465465
Not in Maven Central, download manually from http://kasparov.skife.org/csv/csv-1.0.jar and install with:
466-
mkdir C:\Java\skife.org\
467-
curl https://repo.marketcetera.org/maven/org/skife/kasparov/csv/1.0/csv-1.0.jar -o C:\Java\skife.org\csv-1.0.jar
468-
mvn install:install-file -Dfile=C:/Java/skife.org/csv-1.0.jar -DgroupId=org.skife.kasparov -DartifactId=csv -Dversion=1.0 -Dpackaging=jar
466+
curl https://repo.marketcetera.org/maven/org/skife/kasparov/csv/1.0/csv-1.0.jar -o $TMPDIR/csv-1.0.jar
467+
mvn install:install-file -Dfile=$TMPDIR/csv-1.0.jar -DgroupId=org.skife.kasparov -DartifactId=csv -Dversion=1.0 -Dpackaging=jar
469468
-->
470469
<dependency>
471470
<groupId>org.skife.kasparov</groupId>

src/conf/checkstyle/checkstyle.xml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,32 @@ limitations under the License.
5353
<property name="max" value="160"/>
5454
</module>
5555
<module name="TreeWalker">
56+
<module name="AvoidStarImport" />
57+
<module name="FinalLocalVariable" />
58+
<module name="IllegalImport" />
59+
<module name="ImportOrder">
60+
<property name="option" value="top" />
61+
<property name="groups" value="java,javax,org" />
62+
<property name="ordered" value="true" />
63+
<property name="separated" value="true" />
64+
</module>
65+
<module name="LeftCurly" />
66+
<module name="LocalFinalVariableName" />
67+
<module name="MissingOverride" />
68+
<module name="ModifierOrder" />
69+
<module name="NeedBraces" />
70+
<module name="NeedBraces" />
5671
<module name="OperatorWrap">
5772
<property name="option" value="eol" />
5873
</module>
59-
<module name="ImportOrder">
60-
<property name="option" value="top"/>
61-
<property name="groups" value="java,javax,org"/>
62-
<property name="ordered" value="true"/>
63-
<property name="separated" value="true"/>
64-
</module>
74+
<module name="RedundantImport" />
75+
<module name="RedundantModifier" />
76+
<module name="RightCurly" />
77+
<module name="UnusedImports" />
78+
<module name="UpperEll" />
6579
<module name="WhitespaceAfter" />
6680
<module name="WhitespaceAround" />
67-
<module name="WhitespaceAroundCheck" />
81+
<module name="WhitespaceAroundCheck" />
6882
</module>
69-
7083
</module>
7184

src/test/java/org/apache/commons/csv/CSVBenchmark.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ private Reader getReader() {
7878
*/
7979
@Setup
8080
public void init() throws IOException {
81-
InputStream in = this.getClass().getClassLoader().getResourceAsStream(
82-
"org/apache/commons/csv/perf/worldcitiespop.txt.gz");
83-
try (final InputStream gzin = new GZIPInputStream(in, 8192)) {
81+
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream("org/apache/commons/csv/perf/worldcitiespop.txt.gz");
82+
InputStream gzin = new GZIPInputStream(in, 8192)) {
8483
this.data = IOUtils.toString(gzin, StandardCharsets.ISO_8859_1);
8584
}
8685
}
@@ -89,9 +88,9 @@ public void init() throws IOException {
8988
public int parseCommonsCSV(final Blackhole bh) throws Exception {
9089
int count = 0;
9190

92-
try (final Reader in = getReader()) {
91+
try (Reader in = getReader()) {
9392
final CSVFormat format = CSVFormat.Builder.create().setSkipHeaderRecord(true).build();
94-
Iterator<CSVRecord> iter = format.parse(in).iterator();
93+
final Iterator<CSVRecord> iter = format.parse(in).iterator();
9594
while (iter.hasNext()) {
9695
count++;
9796
iter.next();
@@ -106,7 +105,7 @@ public int parseCommonsCSV(final Blackhole bh) throws Exception {
106105
public int parseGenJavaCSV(final Blackhole bh) throws Exception {
107106
int count = 0;
108107

109-
try (final Reader in = getReader()) {
108+
try (Reader in = getReader()) {
110109
final CsvReader reader = new CsvReader(in);
111110
reader.setFieldDelimiter(',');
112111
while (reader.readLine() != null) {
@@ -122,7 +121,7 @@ public int parseGenJavaCSV(final Blackhole bh) throws Exception {
122121
public int parseJavaCSV(final Blackhole bh) throws Exception {
123122
int count = 0;
124123

125-
try (final Reader in = getReader()) {
124+
try (Reader in = getReader()) {
126125
final com.csvreader.CsvReader reader = new com.csvreader.CsvReader(in, ',');
127126
reader.setRecordDelimiter('\n');
128127
while (reader.readRecord()) {
@@ -141,7 +140,7 @@ public int parseOpenCSV(final Blackhole bh) throws Exception {
141140
final com.opencsv.CSVParser parser = new CSVParserBuilder()
142141
.withSeparator(',').withIgnoreQuotations(true).build();
143142

144-
try (final Reader in = getReader()) {
143+
try (Reader in = getReader()) {
145144
final com.opencsv.CSVReader reader = new CSVReaderBuilder(in).withSkipLines(1).withCSVParser(parser).build();
146145
while (reader.readNext() != null) {
147146
count++;
@@ -158,7 +157,7 @@ public int parseSkifeCSV(final Blackhole bh) throws Exception {
158157
reader.setSeperator(',');
159158
final CountingReaderCallback callback = new CountingReaderCallback();
160159

161-
try (final Reader in = getReader()) {
160+
try (Reader in = getReader()) {
162161
reader.parse(in, callback);
163162
}
164163

@@ -170,7 +169,7 @@ public int parseSkifeCSV(final Blackhole bh) throws Exception {
170169
public int parseSuperCSV(final Blackhole bh) throws Exception {
171170
int count = 0;
172171

173-
try (final CsvListReader reader = new CsvListReader(getReader(), CsvPreference.STANDARD_PREFERENCE)) {
172+
try (CsvListReader reader = new CsvListReader(getReader(), CsvPreference.STANDARD_PREFERENCE)) {
174173
while (reader.read() != null) {
175174
count++;
176175
}

src/test/java/org/apache/commons/csv/CSVFileParserTest.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ public void testCSVFile(final File testFile) throws Exception {
6868
boolean checkComments = false;
6969
for (int i = 1; i < split.length; i++) {
7070
final String option = split[i];
71-
final String[] option_parts = option.split("=", 2);
72-
if ("IgnoreEmpty".equalsIgnoreCase(option_parts[0])) {
73-
format = format.withIgnoreEmptyLines(Boolean.parseBoolean(option_parts[1]));
74-
} else if ("IgnoreSpaces".equalsIgnoreCase(option_parts[0])) {
75-
format = format.withIgnoreSurroundingSpaces(Boolean.parseBoolean(option_parts[1]));
76-
} else if ("CommentStart".equalsIgnoreCase(option_parts[0])) {
77-
format = format.withCommentMarker(option_parts[1].charAt(0));
78-
} else if ("CheckComments".equalsIgnoreCase(option_parts[0])) {
71+
final String[] optionParts = option.split("=", 2);
72+
if ("IgnoreEmpty".equalsIgnoreCase(optionParts[0])) {
73+
format = format.withIgnoreEmptyLines(Boolean.parseBoolean(optionParts[1]));
74+
} else if ("IgnoreSpaces".equalsIgnoreCase(optionParts[0])) {
75+
format = format.withIgnoreSurroundingSpaces(Boolean.parseBoolean(optionParts[1]));
76+
} else if ("CommentStart".equalsIgnoreCase(optionParts[0])) {
77+
format = format.withCommentMarker(optionParts[1].charAt(0));
78+
} else if ("CheckComments".equalsIgnoreCase(optionParts[0])) {
7979
checkComments = true;
8080
} else {
8181
fail(testFile.getName() + " unexpected option: " + option);
@@ -86,7 +86,7 @@ public void testCSVFile(final File testFile) throws Exception {
8686

8787
// Now parse the file and compare against the expected results
8888
// We use a buffered reader internally so no need to create one here.
89-
try (final CSVParser parser = CSVParser.parse(new File(BASE_DIR, split[0]), Charset.defaultCharset(), format)) {
89+
try (CSVParser parser = CSVParser.parse(new File(BASE_DIR, split[0]), Charset.defaultCharset(), format)) {
9090
for (final CSVRecord record : parser) {
9191
String parsed = Arrays.toString(record.values());
9292
final String comment = record.getComment();
@@ -113,14 +113,14 @@ public void testCSVUrl(final File testFile) throws Exception {
113113
boolean checkComments = false;
114114
for (int i = 1; i < split.length; i++) {
115115
final String option = split[i];
116-
final String[] option_parts = option.split("=", 2);
117-
if ("IgnoreEmpty".equalsIgnoreCase(option_parts[0])) {
118-
format = format.withIgnoreEmptyLines(Boolean.parseBoolean(option_parts[1]));
119-
} else if ("IgnoreSpaces".equalsIgnoreCase(option_parts[0])) {
120-
format = format.withIgnoreSurroundingSpaces(Boolean.parseBoolean(option_parts[1]));
121-
} else if ("CommentStart".equalsIgnoreCase(option_parts[0])) {
122-
format = format.withCommentMarker(option_parts[1].charAt(0));
123-
} else if ("CheckComments".equalsIgnoreCase(option_parts[0])) {
116+
final String[] optionParts = option.split("=", 2);
117+
if ("IgnoreEmpty".equalsIgnoreCase(optionParts[0])) {
118+
format = format.withIgnoreEmptyLines(Boolean.parseBoolean(optionParts[1]));
119+
} else if ("IgnoreSpaces".equalsIgnoreCase(optionParts[0])) {
120+
format = format.withIgnoreSurroundingSpaces(Boolean.parseBoolean(optionParts[1]));
121+
} else if ("CommentStart".equalsIgnoreCase(optionParts[0])) {
122+
format = format.withCommentMarker(optionParts[1].charAt(0));
123+
} else if ("CheckComments".equalsIgnoreCase(optionParts[0])) {
124124
checkComments = true;
125125
} else {
126126
fail(testFile.getName() + " unexpected option: " + option);
@@ -131,7 +131,7 @@ public void testCSVUrl(final File testFile) throws Exception {
131131

132132
// Now parse the file and compare against the expected results
133133
final URL resource = ClassLoader.getSystemResource("org/apache/commons/csv/CSVFileParser/" + split[0]);
134-
try (final CSVParser parser = CSVParser.parse(resource, StandardCharsets.UTF_8, format)) {
134+
try (CSVParser parser = CSVParser.parse(resource, StandardCharsets.UTF_8, format)) {
135135
for (final CSVRecord record : parser) {
136136
String parsed = Arrays.toString(record.values());
137137
final String comment = record.getComment();

src/test/java/org/apache/commons/csv/CSVFormatTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ public void testRFC4180() {
10131013
public void testSerialization() throws Exception {
10141014
final ByteArrayOutputStream out = new ByteArrayOutputStream();
10151015

1016-
try (final ObjectOutputStream oos = new ObjectOutputStream(out)) {
1016+
try (ObjectOutputStream oos = new ObjectOutputStream(out)) {
10171017
oos.writeObject(CSVFormat.DEFAULT);
10181018
oos.flush();
10191019
}
@@ -1043,8 +1043,8 @@ public void testToString() {
10431043
@Test
10441044
public void testToStringAndWithCommentMarkerTakingCharacter() {
10451045

1046-
final CSVFormat.Predefined csvFormat_Predefined = CSVFormat.Predefined.Default;
1047-
final CSVFormat csvFormat = csvFormat_Predefined.getFormat();
1046+
final CSVFormat.Predefined csvFormatPredefined = CSVFormat.Predefined.Default;
1047+
final CSVFormat csvFormat = csvFormatPredefined.getFormat();
10481048

10491049
assertNull(csvFormat.getEscapeCharacter());
10501050
assertTrue(csvFormat.isQuoteCharacterSet());

0 commit comments

Comments
 (0)