Skip to content

Commit 1e01f7e

Browse files
author
Gary Gregory
committed
Use final and remove trailing whitespace.
1 parent 072fa70 commit 1e01f7e

8 files changed

Lines changed: 50 additions & 46 deletions

File tree

checkstyle.xml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
See the License for the specific language governing permissions and
1616
limitations under the License.
1717
-->
18-
1918
<!DOCTYPE module PUBLIC
2019
"-//Checkstyle//DTD Checkstyle Configuration 1.2//EN"
2120
"https://checkstyle.org/dtds/configuration_1_2.dtd">
22-
2321
<!-- commons lang customization of default Checkstyle behavior -->
2422
<module name="Checker">
2523
<property name="localeLanguage" value="en"/>
@@ -34,12 +32,18 @@ limitations under the License.
3432
<property name="max" value="160"/>
3533
</module>
3634
<module name="TreeWalker">
37-
<module name="AvoidStarImport"/>
38-
<module name="RedundantImport"/>
39-
<module name="UnusedImports"/>
40-
<module name="NeedBraces"/>
41-
<module name="LeftCurly"/>
42-
<module name="JavadocMethod">
43-
</module>
35+
<module name="AvoidStarImport"/>
36+
<module name="RedundantImport"/>
37+
<module name="UnusedImports"/>
38+
<module name="NeedBraces"/>
39+
<module name="LeftCurly"/>
40+
<module name="JavadocMethod">
41+
</module>
42+
<!-- No Trailing whitespace -->
43+
<module name="Regexp">
44+
<property name="format" value="[ \t]+$"/>
45+
<property name="illegalPattern" value="true"/>
46+
<property name="message" value="Trailing whitespace"/>
47+
</module>
4448
</module>
4549
</module>

src/main/java/org/apache/commons/io/UncheckedIOExceptions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public class UncheckedIOExceptions {
3333
* <p>
3434
* This method exists because there is no String constructor in UncheckedIOException.
3535
* </p>
36-
*
36+
*
3737
* @param message the detail message.
3838
* @return a new UncheckedIOException.
3939
*/
40-
public static UncheckedIOException create(Object message) {
40+
public static UncheckedIOException create(final Object message) {
4141
final String string = Objects.toString(message);
4242
return new UncheckedIOException(string, new IOException(string));
4343
}
@@ -47,12 +47,12 @@ public static UncheckedIOException create(Object message) {
4747
* <p>
4848
* This method exists because there is no String constructor in UncheckedIOException.
4949
* </p>
50-
*
50+
*
5151
* @param message the detail message.
5252
* @param e cause the {@code IOException}.
5353
* @return a new UncheckedIOException.
5454
*/
55-
public static UncheckedIOException create(Object message, final IOException e) {
55+
public static UncheckedIOException create(final Object message, final IOException e) {
5656
return new UncheckedIOException(Objects.toString(message), e);
5757
}
5858

src/main/java/org/apache/commons/io/file/PathUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ public static DirectoryStream<Path> newDirectoryStream(final Path dir, final Pat
813813
/**
814814
* Creates a new OutputStream by opening or creating a file, returning an output stream that may be used to write bytes
815815
* to the file.
816-
*
816+
*
817817
* @param path the Path.
818818
* @param append Whether or not to append.
819819
*
@@ -825,7 +825,7 @@ public static DirectoryStream<Path> newDirectoryStream(final Path dir, final Pat
825825
public static OutputStream newOutputStream(final Path path, final boolean append) throws IOException {
826826
// @formatter:off
827827
return Files.newOutputStream(path, append ?
828-
new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.APPEND} :
828+
new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.APPEND} :
829829
new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING});
830830
// @formatter:on
831831
}

src/main/java/org/apache/commons/io/input/BrokenInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class BrokenInputStream extends InputStream {
3737
* @since 2.12.0
3838
*/
3939
public static final BrokenInputStream INSTANCE = new BrokenInputStream();
40-
40+
4141
/**
4242
* The exception that is thrown by all methods of this class.
4343
*/

src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public FileWriterWithEncoding(final String fileName, final String charsetName, f
240240

241241
/**
242242
* Closes the stream.
243-
*
243+
*
244244
* @throws IOException if an I/O error occurs.
245245
*/
246246
@Override
@@ -250,7 +250,7 @@ public void close() throws IOException {
250250

251251
/**
252252
* Flushes the stream.
253-
*
253+
*
254254
* @throws IOException if an I/O error occurs.
255255
*/
256256
@Override
@@ -260,7 +260,7 @@ public void flush() throws IOException {
260260

261261
/**
262262
* Writes the characters from an array.
263-
*
263+
*
264264
* @param chr the characters to write
265265
* @throws IOException if an I/O error occurs.
266266
*/
@@ -271,7 +271,7 @@ public void write(final char[] chr) throws IOException {
271271

272272
/**
273273
* Writes the specified characters from an array.
274-
*
274+
*
275275
* @param chr the characters to write
276276
* @param st The start offset
277277
* @param end The number of characters to write
@@ -284,7 +284,7 @@ public void write(final char[] chr, final int st, final int end) throws IOExcept
284284

285285
/**
286286
* Writes a character.
287-
*
287+
*
288288
* @param idx the character to write
289289
* @throws IOException if an I/O error occurs.
290290
*/
@@ -295,7 +295,7 @@ public void write(final int idx) throws IOException {
295295

296296
/**
297297
* Writes the characters from a string.
298-
*
298+
*
299299
* @param str the string to write
300300
* @throws IOException if an I/O error occurs.
301301
*/
@@ -306,7 +306,7 @@ public void write(final String str) throws IOException {
306306

307307
/**
308308
* Writes the specified characters from a string.
309-
*
309+
*
310310
* @param str the string to write
311311
* @param st The start offset
312312
* @param end The number of characters to write

src/main/java/org/apache/commons/io/output/UncheckedFilterWriter.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ public static UncheckedFilterWriter on(final Writer writer) {
4949
* @param writer a Writer object providing the underlying stream.
5050
* @throws NullPointerException if {@code writer} is {@code null}.
5151
*/
52-
protected UncheckedFilterWriter(Writer writer) {
52+
protected UncheckedFilterWriter(final Writer writer) {
5353
super(writer);
5454
}
5555

5656
/**
5757
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
5858
*/
5959
@Override
60-
public Writer append(char c) throws UncheckedIOException {
60+
public Writer append(final char c) throws UncheckedIOException {
6161
try {
6262
return super.append(c);
63-
} catch (IOException e) {
63+
} catch (final IOException e) {
6464
throw uncheck(e);
6565
}
6666
}
@@ -69,10 +69,10 @@ public Writer append(char c) throws UncheckedIOException {
6969
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
7070
*/
7171
@Override
72-
public Writer append(CharSequence csq) throws UncheckedIOException {
72+
public Writer append(final CharSequence csq) throws UncheckedIOException {
7373
try {
7474
return super.append(csq);
75-
} catch (IOException e) {
75+
} catch (final IOException e) {
7676
throw uncheck(e);
7777
}
7878
}
@@ -81,10 +81,10 @@ public Writer append(CharSequence csq) throws UncheckedIOException {
8181
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
8282
*/
8383
@Override
84-
public Writer append(CharSequence csq, int start, int end) throws UncheckedIOException {
84+
public Writer append(final CharSequence csq, final int start, final int end) throws UncheckedIOException {
8585
try {
8686
return super.append(csq, start, end);
87-
} catch (IOException e) {
87+
} catch (final IOException e) {
8888
throw uncheck(e);
8989
}
9090
}
@@ -96,7 +96,7 @@ public Writer append(CharSequence csq, int start, int end) throws UncheckedIOExc
9696
public void close() throws UncheckedIOException {
9797
try {
9898
super.close();
99-
} catch (IOException e) {
99+
} catch (final IOException e) {
100100
throw uncheck(e);
101101
}
102102
}
@@ -108,23 +108,23 @@ public void close() throws UncheckedIOException {
108108
public void flush() throws UncheckedIOException {
109109
try {
110110
super.flush();
111-
} catch (IOException e) {
111+
} catch (final IOException e) {
112112
throw uncheck(e);
113113
}
114114
}
115115

116-
private UncheckedIOException uncheck(IOException e) {
116+
private UncheckedIOException uncheck(final IOException e) {
117117
return new UncheckedIOException(e);
118118
}
119119

120120
/**
121121
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
122122
*/
123123
@Override
124-
public void write(char[] cbuf) throws UncheckedIOException {
124+
public void write(final char[] cbuf) throws UncheckedIOException {
125125
try {
126126
super.write(cbuf);
127-
} catch (IOException e) {
127+
} catch (final IOException e) {
128128
throw uncheck(e);
129129
}
130130
}
@@ -133,10 +133,10 @@ public void write(char[] cbuf) throws UncheckedIOException {
133133
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
134134
*/
135135
@Override
136-
public void write(char[] cbuf, int off, int len) throws UncheckedIOException {
136+
public void write(final char[] cbuf, final int off, final int len) throws UncheckedIOException {
137137
try {
138138
super.write(cbuf, off, len);
139-
} catch (IOException e) {
139+
} catch (final IOException e) {
140140
throw uncheck(e);
141141
}
142142
}
@@ -145,10 +145,10 @@ public void write(char[] cbuf, int off, int len) throws UncheckedIOException {
145145
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
146146
*/
147147
@Override
148-
public void write(int c) throws UncheckedIOException {
148+
public void write(final int c) throws UncheckedIOException {
149149
try {
150150
super.write(c);
151-
} catch (IOException e) {
151+
} catch (final IOException e) {
152152
throw uncheck(e);
153153
}
154154
}
@@ -157,10 +157,10 @@ public void write(int c) throws UncheckedIOException {
157157
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
158158
*/
159159
@Override
160-
public void write(String str) throws UncheckedIOException {
160+
public void write(final String str) throws UncheckedIOException {
161161
try {
162162
super.write(str);
163-
} catch (IOException e) {
163+
} catch (final IOException e) {
164164
throw uncheck(e);
165165
}
166166
}
@@ -169,10 +169,10 @@ public void write(String str) throws UncheckedIOException {
169169
* Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}.
170170
*/
171171
@Override
172-
public void write(String str, int off, int len) throws UncheckedIOException {
172+
public void write(final String str, final int off, final int len) throws UncheckedIOException {
173173
try {
174174
super.write(str, off, len);
175-
} catch (IOException e) {
175+
} catch (final IOException e) {
176176
throw uncheck(e);
177177
}
178178
}

src/test/java/org/apache/commons/io/UncheckedIOExceptionsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void testCreate() {
3131
final Object message = "test";
3232
try {
3333
throw UncheckedIOExceptions.create(message);
34-
} catch (UncheckedIOException e) {
34+
} catch (final UncheckedIOException e) {
3535
assertEquals(message, e.getMessage());
3636
assertEquals(message, e.getCause().getMessage());
3737
}
@@ -45,7 +45,7 @@ public void testCreateWithException() {
4545
final IOException ioe = new IOException(message2.toString());
4646
try {
4747
throw UncheckedIOExceptions.create(message1, ioe);
48-
} catch (UncheckedIOException e) {
48+
} catch (final UncheckedIOException e) {
4949
assertEquals(message1, e.getMessage());
5050
assertEquals(message2, e.getCause().getMessage());
5151
}

src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void constructor_File_directory() {
5959
});
6060
assertFalse(file1.exists());
6161
}
62-
62+
6363
@Test
6464
public void constructor_File_encoding_badEncoding() {
6565
assertThrows(IOException.class, () -> {

0 commit comments

Comments
 (0)