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-io.git
The following commit(s) were added to refs/heads/master by this push: new 1e01f7e Use final and remove trailing whitespace. 1e01f7e is described below commit 1e01f7eb64a57cfd56dd9183ddca63a34b6925af Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Fri Sep 3 10:17:53 2021 -0400 Use final and remove trailing whitespace. --- checkstyle.xml | 22 +++++++----- .../apache/commons/io/UncheckedIOExceptions.java | 8 ++--- .../java/org/apache/commons/io/file/PathUtils.java | 4 +-- .../apache/commons/io/input/BrokenInputStream.java | 2 +- .../commons/io/output/FileWriterWithEncoding.java | 14 ++++---- .../commons/io/output/UncheckedFilterWriter.java | 40 +++++++++++----------- .../commons/io/UncheckedIOExceptionsTest.java | 4 +-- .../io/output/FileWriterWithEncodingTest.java | 2 +- 8 files changed, 50 insertions(+), 46 deletions(-) diff --git a/checkstyle.xml b/checkstyle.xml index af2ee30..55c7fa1 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -15,11 +15,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - <!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.2//EN" "https://checkstyle.org/dtds/configuration_1_2.dtd"> - <!-- commons lang customization of default Checkstyle behavior --> <module name="Checker"> <property name="localeLanguage" value="en"/> @@ -34,12 +32,18 @@ limitations under the License. <property name="max" value="160"/> </module> <module name="TreeWalker"> - <module name="AvoidStarImport"/> - <module name="RedundantImport"/> - <module name="UnusedImports"/> - <module name="NeedBraces"/> - <module name="LeftCurly"/> - <module name="JavadocMethod"> - </module> + <module name="AvoidStarImport"/> + <module name="RedundantImport"/> + <module name="UnusedImports"/> + <module name="NeedBraces"/> + <module name="LeftCurly"/> + <module name="JavadocMethod"> + </module> + <!-- No Trailing whitespace --> + <module name="Regexp"> + <property name="format" value="[ \t]+$"/> + <property name="illegalPattern" value="true"/> + <property name="message" value="Trailing whitespace"/> + </module> </module> </module> diff --git a/src/main/java/org/apache/commons/io/UncheckedIOExceptions.java b/src/main/java/org/apache/commons/io/UncheckedIOExceptions.java index 2baf06f..f8f3ff7 100644 --- a/src/main/java/org/apache/commons/io/UncheckedIOExceptions.java +++ b/src/main/java/org/apache/commons/io/UncheckedIOExceptions.java @@ -33,11 +33,11 @@ public class UncheckedIOExceptions { * <p> * This method exists because there is no String constructor in UncheckedIOException. * </p> - * + * * @param message the detail message. * @return a new UncheckedIOException. */ - public static UncheckedIOException create(Object message) { + public static UncheckedIOException create(final Object message) { final String string = Objects.toString(message); return new UncheckedIOException(string, new IOException(string)); } @@ -47,12 +47,12 @@ public class UncheckedIOExceptions { * <p> * This method exists because there is no String constructor in UncheckedIOException. * </p> - * + * * @param message the detail message. * @param e cause the {@code IOException}. * @return a new UncheckedIOException. */ - public static UncheckedIOException create(Object message, final IOException e) { + public static UncheckedIOException create(final Object message, final IOException e) { return new UncheckedIOException(Objects.toString(message), e); } diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java b/src/main/java/org/apache/commons/io/file/PathUtils.java index f1075b9..fe2e08a 100644 --- a/src/main/java/org/apache/commons/io/file/PathUtils.java +++ b/src/main/java/org/apache/commons/io/file/PathUtils.java @@ -813,7 +813,7 @@ public final class PathUtils { /** * Creates a new OutputStream by opening or creating a file, returning an output stream that may be used to write bytes * to the file. - * + * * @param path the Path. * @param append Whether or not to append. * @@ -825,7 +825,7 @@ public final class PathUtils { public static OutputStream newOutputStream(final Path path, final boolean append) throws IOException { // @formatter:off return Files.newOutputStream(path, append ? - new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.APPEND} : + new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.APPEND} : new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING}); // @formatter:on } diff --git a/src/main/java/org/apache/commons/io/input/BrokenInputStream.java b/src/main/java/org/apache/commons/io/input/BrokenInputStream.java index d96cea0..731b032 100644 --- a/src/main/java/org/apache/commons/io/input/BrokenInputStream.java +++ b/src/main/java/org/apache/commons/io/input/BrokenInputStream.java @@ -37,7 +37,7 @@ public class BrokenInputStream extends InputStream { * @since 2.12.0 */ public static final BrokenInputStream INSTANCE = new BrokenInputStream(); - + /** * The exception that is thrown by all methods of this class. */ diff --git a/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java b/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java index 23b8996..3d7cfb2 100644 --- a/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java +++ b/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java @@ -240,7 +240,7 @@ public class FileWriterWithEncoding extends Writer { /** * Closes the stream. - * + * * @throws IOException if an I/O error occurs. */ @Override @@ -250,7 +250,7 @@ public class FileWriterWithEncoding extends Writer { /** * Flushes the stream. - * + * * @throws IOException if an I/O error occurs. */ @Override @@ -260,7 +260,7 @@ public class FileWriterWithEncoding extends Writer { /** * Writes the characters from an array. - * + * * @param chr the characters to write * @throws IOException if an I/O error occurs. */ @@ -271,7 +271,7 @@ public class FileWriterWithEncoding extends Writer { /** * Writes the specified characters from an array. - * + * * @param chr the characters to write * @param st The start offset * @param end The number of characters to write @@ -284,7 +284,7 @@ public class FileWriterWithEncoding extends Writer { /** * Writes a character. - * + * * @param idx the character to write * @throws IOException if an I/O error occurs. */ @@ -295,7 +295,7 @@ public class FileWriterWithEncoding extends Writer { /** * Writes the characters from a string. - * + * * @param str the string to write * @throws IOException if an I/O error occurs. */ @@ -306,7 +306,7 @@ public class FileWriterWithEncoding extends Writer { /** * Writes the specified characters from a string. - * + * * @param str the string to write * @param st The start offset * @param end The number of characters to write diff --git a/src/main/java/org/apache/commons/io/output/UncheckedFilterWriter.java b/src/main/java/org/apache/commons/io/output/UncheckedFilterWriter.java index e9ad59b..5be5c1f 100644 --- a/src/main/java/org/apache/commons/io/output/UncheckedFilterWriter.java +++ b/src/main/java/org/apache/commons/io/output/UncheckedFilterWriter.java @@ -49,7 +49,7 @@ public class UncheckedFilterWriter extends FilterWriter { * @param writer a Writer object providing the underlying stream. * @throws NullPointerException if {@code writer} is {@code null}. */ - protected UncheckedFilterWriter(Writer writer) { + protected UncheckedFilterWriter(final Writer writer) { super(writer); } @@ -57,10 +57,10 @@ public class UncheckedFilterWriter extends FilterWriter { * Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}. */ @Override - public Writer append(char c) throws UncheckedIOException { + public Writer append(final char c) throws UncheckedIOException { try { return super.append(c); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } @@ -69,10 +69,10 @@ public class UncheckedFilterWriter extends FilterWriter { * Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}. */ @Override - public Writer append(CharSequence csq) throws UncheckedIOException { + public Writer append(final CharSequence csq) throws UncheckedIOException { try { return super.append(csq); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } @@ -81,10 +81,10 @@ public class UncheckedFilterWriter extends FilterWriter { * Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}. */ @Override - public Writer append(CharSequence csq, int start, int end) throws UncheckedIOException { + public Writer append(final CharSequence csq, final int start, final int end) throws UncheckedIOException { try { return super.append(csq, start, end); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } @@ -96,7 +96,7 @@ public class UncheckedFilterWriter extends FilterWriter { public void close() throws UncheckedIOException { try { super.close(); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } @@ -108,12 +108,12 @@ public class UncheckedFilterWriter extends FilterWriter { public void flush() throws UncheckedIOException { try { super.flush(); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } - private UncheckedIOException uncheck(IOException e) { + private UncheckedIOException uncheck(final IOException e) { return new UncheckedIOException(e); } @@ -121,10 +121,10 @@ public class UncheckedFilterWriter extends FilterWriter { * Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}. */ @Override - public void write(char[] cbuf) throws UncheckedIOException { + public void write(final char[] cbuf) throws UncheckedIOException { try { super.write(cbuf); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } @@ -133,10 +133,10 @@ public class UncheckedFilterWriter extends FilterWriter { * Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}. */ @Override - public void write(char[] cbuf, int off, int len) throws UncheckedIOException { + public void write(final char[] cbuf, final int off, final int len) throws UncheckedIOException { try { super.write(cbuf, off, len); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } @@ -145,10 +145,10 @@ public class UncheckedFilterWriter extends FilterWriter { * Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}. */ @Override - public void write(int c) throws UncheckedIOException { + public void write(final int c) throws UncheckedIOException { try { super.write(c); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } @@ -157,10 +157,10 @@ public class UncheckedFilterWriter extends FilterWriter { * Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}. */ @Override - public void write(String str) throws UncheckedIOException { + public void write(final String str) throws UncheckedIOException { try { super.write(str); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } @@ -169,10 +169,10 @@ public class UncheckedFilterWriter extends FilterWriter { * Calls this method's super and rethrow {@link IOException} as {@link UncheckedIOException}. */ @Override - public void write(String str, int off, int len) throws UncheckedIOException { + public void write(final String str, final int off, final int len) throws UncheckedIOException { try { super.write(str, off, len); - } catch (IOException e) { + } catch (final IOException e) { throw uncheck(e); } } diff --git a/src/test/java/org/apache/commons/io/UncheckedIOExceptionsTest.java b/src/test/java/org/apache/commons/io/UncheckedIOExceptionsTest.java index 2344c31..09c393c 100644 --- a/src/test/java/org/apache/commons/io/UncheckedIOExceptionsTest.java +++ b/src/test/java/org/apache/commons/io/UncheckedIOExceptionsTest.java @@ -31,7 +31,7 @@ public class UncheckedIOExceptionsTest { final Object message = "test"; try { throw UncheckedIOExceptions.create(message); - } catch (UncheckedIOException e) { + } catch (final UncheckedIOException e) { assertEquals(message, e.getMessage()); assertEquals(message, e.getCause().getMessage()); } @@ -45,7 +45,7 @@ public class UncheckedIOExceptionsTest { final IOException ioe = new IOException(message2.toString()); try { throw UncheckedIOExceptions.create(message1, ioe); - } catch (UncheckedIOException e) { + } catch (final UncheckedIOException e) { assertEquals(message1, e.getMessage()); assertEquals(message2, e.getCause().getMessage()); } diff --git a/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java b/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java index d20ed2d..a0892de 100644 --- a/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java +++ b/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java @@ -59,7 +59,7 @@ public class FileWriterWithEncodingTest { }); assertFalse(file1.exists()); } - + @Test public void constructor_File_encoding_badEncoding() { assertThrows(IOException.class, () -> {