Skip to content

Commit

Permalink
Add violations for Apache commons-io
Browse files Browse the repository at this point in the history
References #21.
  • Loading branch information
gaul committed Jan 21, 2025
1 parent f244c61 commit 537be7d
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 2 deletions.
68 changes: 67 additions & 1 deletion modernizer-maven-plugin/src/main/resources/modernizer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ violation names use the same format that javap emits.
<violation>
<name>com/google/common/io/ByteStreams.copy:(Ljava/io/InputStream;Ljava/io/OutputStream;)J</name>
<version>9</version>
<comment>Prefer java.io.InputStream.transferTo</comment>
<comment>Prefer java.io.InputStream.transferTo(InputStream, OutputStream)</comment>
</violation>

<violation>
Expand Down Expand Up @@ -713,6 +713,66 @@ violation names use the same format that javap emits.
<comment>Prefer java.nio.file.Files.readAllLines(java.nio.file.Path, java.nio.charset.Charset)</comment>
</violation>

<violation>
<name>org/apache/commons/io/IOUtils.copy:(Ljava/io/InputStream;Ljava/io/OutputStream;)I</name>
<version>9</version>
<comment>Prefer java.io.InputStream.transferTo(InputStream, OutputStream)</comment>
</violation>

<violation>
<name>org/apache/commons/io/IOUtils.copyLarge:(Ljava/io/InputStream;Ljava/io/OutputStream;)J</name>
<version>9</version>
<comment>Prefer java.io.InputStream.transferTo(InputStream, OutputStream)</comment>
</violation>

<violation>
<name>org/apache/commons/io/IOUtils.copy:(Ljava/io/Reader;Ljava/io/Writer;)I</name>
<version>9</version>
<comment>Prefer java.io.InputStream.transferTo(Reader, Writer)</comment>
</violation>

<violation>
<name>org/apache/commons/io/IOUtils.copyLarge:(Ljava/io/Reader;Ljava/io/Writer;)J</name>
<version>9</version>
<comment>Prefer java.io.InputStream.transferTo(Reader, Writer)</comment>
</violation>

<violation>
<name>org/apache/commons/io/IOUtils.skipFully:(Ljava/io/InputStream;J)V</name>
<version>12</version>
<comment>Prefer java.io.InputStream.skipNBytes(long)</comment>
</violation>

<violation>
<name>org/apache/commons/io/IOUtils.toByteArray:(Ljava/io/InputStream;)[B</name>
<version>9</version>
<comment>Prefer java.io.InputStream.readAllBytes(InputStream)</comment>
</violation>

<violation>
<name>org/apache/commons/io/output/NullOutputStream.NULL_OUTPUT_STREAM:Lorg/apache/commons/io/output/NullOutputStream;</name>
<version>11</version>
<comment>Prefer java.io.OutputStream.nullOutputStream()</comment>
</violation>

<violation>
<name>org/apache/commons/io/output/NullOutputStream."&lt;init&gt;":()V</name>
<version>11</version>
<comment>Prefer java.io.OutputStream.nullOutputStream()</comment>
</violation>

<violation>
<name>org/apache/commons/io/output/NullWriter.NULL_WRITER:Lorg/apache/commons/io/output/NullWriter;</name>
<version>11</version>
<comment>Prefer java.io.Writer.nullWriter()</comment>
</violation>

<violation>
<name>org/apache/commons/io/output/NullWriter."&lt;init&gt;":()V</name>
<version>11</version>
<comment>Prefer java.io.Writer.nullWriter()</comment>
</violation>

<violation>
<name>sun/misc/BASE64Decoder.decodeBuffer:(Ljava/lang/String;)[B</name>
<version>8</version>
Expand Down Expand Up @@ -1193,6 +1253,12 @@ violation names use the same format that javap emits.
<comment>Prefer java.io.Writer.nullWriter()</comment>
</violation>

<violation>
<name>com/google/common/io/CharStreams.skipFully:(Ljava/io/Reader;J)V</name>
<version>12</version>
<comment>Prefer java.io.InputStream.skipNBytes(long)</comment>
</violation>

<violation>
<name>com/google/common/io/Files.toString:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/lang/String;</name>
<version>11</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.NetworkInterface;
import java.net.URI;
Expand Down Expand Up @@ -95,6 +97,9 @@
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.io.output.NullWriter;
import org.apache.commons.lang3.StringUtils;
import org.gaul.modernizer_maven_plugin
.SuppressModernizerTestClasses.SuppressedOnClass;
Expand Down Expand Up @@ -628,7 +633,6 @@ private static void method() throws Exception {
Sets.unmodifiableNavigableSet(new TreeSet<Object>());
Sets.synchronizedNavigableSet(new TreeSet<Object>());
BaseEncoding.base64();
ByteStreams.copy((InputStream) null, (OutputStream) null);
Files.toByteArray((File) null);
Chars.compare((char) 0, (char) 0);
Ints.compare(0, 0);
Expand Down Expand Up @@ -771,6 +775,12 @@ private static class Java9Violations {
@SuppressWarnings("deprecation")
private static void method() throws Exception {
ByteStreams.toByteArray((InputStream) null);
ByteStreams.copy((InputStream) null, (OutputStream) null);
IOUtils.copy((InputStream) null, (OutputStream) null);
IOUtils.copyLarge((InputStream) null, (OutputStream) null);
IOUtils.copy((Reader) null, (Writer) null);
IOUtils.copyLarge((Reader) null, (Writer) null);
IOUtils.toByteArray((InputStream) null);
new Byte((String) null);
new Double((String) null);
new Short((String) null);
Expand Down Expand Up @@ -822,8 +832,13 @@ private static void method() throws Exception {
private static class Java11Violations {
@SuppressWarnings("deprecation")
private static void method() throws Exception {
Object object;
ByteStreams.nullOutputStream();
CharStreams.nullWriter();
object = NullOutputStream.NULL_OUTPUT_STREAM;
new NullOutputStream();
object = NullWriter.NULL_WRITER;
new NullWriter();
Files.toString((File) null, (Charset) null);
Files.write("", (File) null, (Charset) null);
new FileReader((File) null, (Charset) null);
Expand All @@ -840,6 +855,8 @@ private static void method() throws Exception {
private static class Java12Violations {
private static void method() throws Exception {
ByteStreams.skipFully(null, 0L);
CharStreams.skipFully(null, 0L);
IOUtils.skipFully((InputStream) null, 0L);
}
}

Expand Down

0 comments on commit 537be7d

Please sign in to comment.