Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add violation for StringReader #291

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modernizer-maven-plugin/src/main/resources/modernizer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ violation names use the same format that javap emits.
<comment>Prefer java.io.OutputStreamWriter(java.io.OutputStream, java.nio.charset.Charset)</comment>
</violation>

<violation>
<name>java/io/StringReader."&lt;init&gt;":(Ljava/lang/String;)V</name>
<version>24</version>
<comment>Prefer java.io.Reader.of(java.lang.CharSequence)</comment>
</violation>

<violation>
<name>java/lang/Byte."&lt;init&gt;":(B)V</name>
<version>5</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.net.HttpURLConnection;
import java.net.NetworkInterface;
import java.net.URLDecoder;
Expand Down Expand Up @@ -399,7 +400,7 @@ public void testAnnotationViolation() throws Exception {

@Test
public void testAllViolations() throws Exception {
Modernizer modernizer = createModernizer("19");
Modernizer modernizer = createModernizer("24");
Collection<ViolationOccurrence> occurrences = modernizer.check(
new ClassReader(AllViolations.class.getName()));
occurrences.addAll(modernizer.check(
Expand All @@ -418,6 +419,8 @@ public void testAllViolations() throws Exception {
new ClassReader(Java18Violations.class.getName())));
occurrences.addAll(modernizer.check(
new ClassReader(Java19Violations.class.getName())));
occurrences.addAll(modernizer.check(
mkarg marked this conversation as resolved.
Show resolved Hide resolved
new ClassReader(Java24Violations.class.getName())));
// must visit inner classes manually
occurrences.addAll(modernizer.check(
new ClassReader(EnumerationTestClass.class.getName())));
Expand Down Expand Up @@ -847,6 +850,12 @@ private static void method() throws Exception {
}
}

private static class Java24Violations {
private static void method() throws Exception {
new StringReader("");
}
}

private enum EnumClass {
}
}