Skip to content

Commit

Permalink
checkstyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Apr 28, 2024
1 parent a2b7789 commit 6280752
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
<module name="NewlineAtEndOfFile"/>

<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
<!--
<module name="SuppressionFilter">
<property name="file" value="${configDirectory}/suppressions.xml"/>
</module>
-->

<!-- https://checkstyle.org/config_filters.html#SuppressWarningsFilter -->
<module name="SuppressWarningsFilter"/>
Expand Down
8 changes: 8 additions & 0 deletions .checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"http://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="src[\\/]testData[\\/]java[\\/].*"
checks="[a-zA-Z0-9]*"/>
</suppressions>
15 changes: 9 additions & 6 deletions src/test/java/io/papermc/asm/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@

@DefaultQualifier(NonNull.class)
public final class TestUtil {
private TestUtil() {
}

public static RewriteRuleVisitorFactory testingVisitorFactory(final RewriteRule rewriteRule) {
return RewriteRuleVisitorFactory.create(Opcodes.ASM9, rewriteRule, ClassInfoProvider.basic());
}

public static Map<String, byte[]> inputBytes(final String className) {
return getClassBytes(new HashMap<>(), className, n -> n + ".class");
return readClassBytes(new HashMap<>(), className, n -> n + ".class");
}

public interface Processor<E extends Throwable> {
Expand All @@ -37,7 +40,7 @@ public interface Processor<E extends Throwable> {

public record DefaultProcessor(RewriteRuleVisitorFactory factory) implements Processor<RuntimeException> {
@Override
public byte[] process(byte[] bytes) {
public byte[] process(final byte[] bytes) {
final ClassReader classReader = new ClassReader(bytes);
final ClassWriter classWriter = new ClassWriter(classReader, 0);
classReader.accept(this.factory.createVisitor(classWriter), 0);
Expand Down Expand Up @@ -102,10 +105,10 @@ public static Map<String, byte[]> processClassBytes(
}

public static Map<String, byte[]> expectedBytes(final String className) {
return getClassBytes(new HashMap<>(), className, n -> "expected/" + n + ".class");
return readClassBytes(new HashMap<>(), className, n -> "expected/" + n + ".class");
}

private static Map<String, byte[]> getClassBytes(
private static Map<String, byte[]> readClassBytes(
final Map<String, byte[]> map,
final String className,
final Function<String, String> classNameMapper
Expand All @@ -123,10 +126,10 @@ private static Map<String, byte[]> getClassBytes(
classReader.accept(node, ClassReader.SKIP_CODE);
map.put(node.name, rootBytes);
for (final InnerClassNode innerNode : node.innerClasses) {
getClassBytes(map, innerNode.name, classNameMapper);
readClassBytes(map, innerNode.name, classNameMapper);
}
}
} catch (IOException e) {
} catch (final IOException e) {
throw new RuntimeException(e);
}
return map;
Expand Down

0 comments on commit 6280752

Please sign in to comment.