Skip to content

Commit

Permalink
sigh. checkstyle test
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Mar 10, 2024
1 parent b1fe79d commit 952cb33
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 45 deletions.
1 change: 0 additions & 1 deletion config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
<module name="StringLiteralEquality"/>

<module name="ModifierOrder"/>
<module name="RedundantModifier"/>

<module name="AnnotationLocation"/>
<module name="MissingOverride"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
final class Builder implements MetadataType.Builder<Comments> {
private final List<String> comments = new ArrayList<>(0);

Builder() {
public Builder() {
}

public void add(String... comments) {
Expand Down
1 change: 0 additions & 1 deletion src/test/java/org/quiltmc/config/NamingSchemeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ public void testNamingSchemeConversions() {
}
}
}

}
21 changes: 10 additions & 11 deletions src/test/java/org/quiltmc/config/old_wrapped/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public void testSerializer() {
section3.field(TrackedValue.create(0, "fire", creator -> {
creator.metadata(Comment.TYPE, comments -> comments.add("This is a field comment!"));
creator.metadata(Comment.TYPE, comments -> comments.add("This is another field comment!"));

}));
section3.field(TrackedValue.create(0, "air"));
});
Expand Down Expand Up @@ -128,7 +127,7 @@ public void testValues() {
Config config = Config.create(ENV, "testmod", "testConfig3", builder -> {
builder.field(TEST_INTEGER = TrackedValue.create(0, "testInteger"));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_LIST = TrackedValue.create(
ValueList.create(0, 1, 2, 3, 4), "testList"
));
Expand Down Expand Up @@ -172,7 +171,7 @@ public void testMetadata() {
));
}));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
});

for (TrackedValue<?> value : config.values()) {
Expand All @@ -189,7 +188,7 @@ public void testFlags() {
Config config = Config.create(ENV, "testmod", "testConfig5", builder -> {
builder.field(TEST_INTEGER = TrackedValue.create(0, "testInteger"));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
});

for (TrackedValue<?> value : config.values()) {
Expand All @@ -209,7 +208,7 @@ public void testConstraints() {
creator.constraint(Constraint.range(5, 10));
}));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
}));

Assertions.assertThrows(TrackedValueException.class, () -> {
Expand All @@ -218,7 +217,7 @@ public void testConstraints() {
creator.constraint(Constraint.range(-10, 10));
}));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
});

TEST_INTEGER.setValue(1000, true);
Expand All @@ -230,7 +229,7 @@ public void testConstraints() {
creator.constraint(Constraint.range(-10, 10));
}));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "test", creator -> {
builder.field(TEST_STRING = TrackedValue.create("blah", "test", creator -> {
creator.constraint(Constraint.matching("[a-zA-Z0-9]+:[a-zA-Z0-9]+"));
}));
});
Expand All @@ -241,7 +240,7 @@ public void testConstraints() {
Config.create(ENV, "testmod", "testConfig9", builder -> {
builder.field(TEST_INTEGER = TrackedValue.create(0, "testInteger", creator -> creator.constraint(Constraint.range(-10, 10))));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("test:id", "test", creator -> creator.constraint(Constraint.matching("[a-zA-Z0-9]+:[a-zA-Z0-9]+"))));
builder.field(TEST_STRING = TrackedValue.create("test:id", "test", creator -> creator.constraint(Constraint.matching("[a-zA-Z0-9]+:[a-zA-Z0-9]+"))));
});
}

Expand All @@ -265,8 +264,8 @@ public void testWrappedConfigs(String id, String format) {

@Test
public void testWrappedConfigs() {
testWrappedConfigs("testConfig10", "toml");
testWrappedConfigs("testConfig11", "json5");
this.testWrappedConfigs("testConfig10", "toml");
this.testWrappedConfigs("testConfig11", "json5");
}

@Test
Expand Down Expand Up @@ -317,7 +316,7 @@ public void testInferredMetadataType() {
));
}));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
});

for (TrackedValue<?> value : config.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class TestValueConfig3 extends WrappedConfig {
public final int a = 0;
public final int b = 1;
public final int c = 2;
@FloatRange(min=0, max=10)
@FloatRange(min = 0, max = 10)
public final int d = 3;
public final Vec3i vec = new Vec3i(100, 200, 300);
public final String whatever = "Riesling";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class TestValueConfig4 extends WrappedConfig {
public final int b = 1;
public final int c = 2;

@IntegerRange(min=0, max=10)
@IntegerRange(min = 0, max = 10)
public final int d = 3;
public final Vec3i vec = new Vec3i(100, 200, 300);

Expand All @@ -53,7 +53,7 @@ public final class TestValueConfig4 extends WrappedConfig {
@Comment("Test section comment 4")
public final Nested nested4 = new Nested(30, 31, 32, 33);

@IntegerRange(min=0, max=10)
@IntegerRange(min = 0, max = 10)
public final ValueList<Integer> ints = ValueList.create(0, 1, 2, 3, 4);

public final ValueList<ValueMap<Integer>> listOfNestedObjects = ValueList.create(ValueMap.builder(0).build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public final class TestWrappedConfig extends WrappedConfig {
public final int b = 1;
public final int c = 2;

@IntegerRange(min=0, max=10)
@IntegerRange(min = 0, max = 10)
public final int d = 3;
public final Vec3i vec = new Vec3i(100, 200, 300);

Expand All @@ -62,7 +62,7 @@ public final class TestWrappedConfig extends WrappedConfig {

public final ValueMap<ValueList<String>> key_binds = ValueMap.builder(ValueList.create("")).build();

@IntegerRange(min=0, max=10)
@IntegerRange(min = 0, max = 10)
public final ValueList<Integer> ints = ValueList.create(0, 1, 2, 3, 4);

public final ValueList<ValueMap<Integer>> listOfNestedObjects = ValueList.create(ValueMap.builder(0).build(),
Expand Down
27 changes: 13 additions & 14 deletions src/test/java/org/quiltmc/config/reflective/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public void testSerializer() {
section3.field(TrackedValue.create(0, "fire", creator -> {
creator.metadata(Comment.TYPE, comments -> comments.add("This is a field comment!"));
creator.metadata(Comment.TYPE, comments -> comments.add("This is another field comment!"));

}));
section3.field(TrackedValue.create(0, "air"));
});
Expand Down Expand Up @@ -119,7 +118,7 @@ public void testValues() {
Config config = Config.create(ENV, "wrapped", "testConfig3", builder -> {
builder.field(TEST_INTEGER = TrackedValue.create(0, "testInteger"));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_LIST = TrackedValue.create(
ValueList.create(0, 1, 2, 3, 4), "testList"
));
Expand Down Expand Up @@ -159,7 +158,7 @@ public void testMetadata() {
"Comment three"
))));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
});

for (TrackedValue<?> value : config.values()) {
Expand All @@ -176,7 +175,7 @@ public void testFlags() {
Config config = Config.create(ENV, "wrapped", "testConfig5", builder -> {
builder.field(TEST_INTEGER = TrackedValue.create(0, "testInteger"));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
});

for (TrackedValue<?> value : config.values()) {
Expand All @@ -196,14 +195,14 @@ public void testConstraints() {
creator.constraint(Constraint.range(5, 10));
}));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
}));

Assertions.assertThrows(TrackedValueException.class, () -> {
Config.create(ENV, "wrapped", "testConfig7", builder -> {
builder.field(TEST_INTEGER = TrackedValue.create(0, "testInteger", creator -> creator.constraint(Constraint.range(-10, 10))));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
});

TEST_INTEGER.setValue(1000, true);
Expand All @@ -213,7 +212,7 @@ public void testConstraints() {
Config.create(ENV, "wrapped", "testConfig8", builder -> {
builder.field(TEST_INTEGER = TrackedValue.create(0, "testInteger", creator -> creator.constraint(Constraint.range(-10, 10))));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "test", creator -> creator.constraint(Constraint.matching("[a-zA-Z0-9]+:[a-zA-Z0-9]+"))));
builder.field(TEST_STRING = TrackedValue.create("blah", "test", creator -> creator.constraint(Constraint.matching("[a-zA-Z0-9]+:[a-zA-Z0-9]+"))));
});

TEST_INTEGER.setValue(1000, true);
Expand All @@ -222,11 +221,11 @@ public void testConstraints() {
Config.create(ENV, "wrapped", "testConfig9", builder -> {
builder.field(TEST_INTEGER = TrackedValue.create(0, "testInteger", creator -> creator.constraint(Constraint.range(-10, 10))));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("test:id", "test", creator -> creator.constraint(Constraint.matching("[a-zA-Z0-9]+:[a-zA-Z0-9]+"))));
builder.field(TEST_STRING = TrackedValue.create("test:id", "test", creator -> creator.constraint(Constraint.matching("[a-zA-Z0-9]+:[a-zA-Z0-9]+"))));
});
}

public void testWrappedConfigs(String id, String format) {
public void testReflectiveConfigs(String id, String format) {
TestReflectiveConfig config = ConfigFactory.create(ENV, "wrapped", id, TestReflectiveConfig.class, builder -> builder.format(format));

for (TrackedValue<?> value : config.values()) {
Expand All @@ -245,9 +244,9 @@ public void testWrappedConfigs(String id, String format) {
}

@Test
public void testWrappedConfigs() {
testWrappedConfigs("testConfig10", "toml");
testWrappedConfigs("testConfig11", "json5");
public void testReflectiveConfigs() {
this.testReflectiveConfigs("testConfig10", "toml");
this.testReflectiveConfigs("testConfig11", "json5");
}

@Test
Expand Down Expand Up @@ -294,7 +293,7 @@ public void testInferredMetadataType() {
"Comment three"
))));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
});

for (TrackedValue<?> value : config.values()) {
Expand All @@ -315,7 +314,7 @@ public void testInheritedMetadata() {
builder.field(TEST_INTEGER = TrackedValue.create(0, "testInteger", c -> c.metadata(SerializedNameConvention.TYPE, b -> b.set(NamingSchemes.KEBAB_CASE))));
builder.field(TEST_BOOLEAN = TrackedValue.create(false, "testBoolean"));
builder.metadata(SerializedNameConvention.TYPE, builder1 -> builder1.set(NamingSchemes.SNAKE_CASE));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.field(TEST_STRING = TrackedValue.create("blah", "testString"));
builder.section("testSection", b -> {
b.field(testSectionTestA[0] = TrackedValue.create(0, "testA"));
b.metadata(SerializedNameConvention.TYPE, builder1 -> builder1.set(NamingSchemes.LOWER_CAMEL_CASE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public class ReadWriteCycleTest extends AbstractConfigTest {
@Test
void testTomlReadWriteCycle() {
TestReflectiveConfig config = ConfigFactory.create(TestUtil.TOML_ENV, "testmod", "tomlTestConfig", TestReflectiveConfig.class);
setUpConfig(config);
this.setUpConfig(config);

TestReflectiveConfig readConfig = ConfigFactory.create(TestUtil.TOML_ENV, "testmod", "tomlTestConfig", TestReflectiveConfig.class);
matchConfigs(config, readConfig);
this.matchConfigs(config, readConfig);
}

@Test
void testJson5ReadWriteCycle() {
TestReflectiveConfig config = ConfigFactory.create(TestUtil.JSON5_ENV, "testmod", "json5TestConfig", TestReflectiveConfig.class);
setUpConfig(config);
this.setUpConfig(config);

TestReflectiveConfig readConfig = ConfigFactory.create(TestUtil.JSON5_ENV, "testmod", "json5TestConfig", TestReflectiveConfig.class);
matchConfigs(config, readConfig);
this.matchConfigs(config, readConfig);
}

/**
Expand Down Expand Up @@ -81,7 +81,7 @@ private void matchConfigs(Config a, Config b) {
}
}

if (aNode instanceof TrackedValue<?>) {
if (aNode instanceof TrackedValue<?>) {
TrackedValue<?> aValue = a.getValue(aNode.key());
TrackedValue<?> bValue = b.getValue(aNode.key());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public class TestEscapingConfig extends ReflectiveConfig {

@SerializedName("servers.server.served")
public final TrackedValue<ValueMap<String>> servers = this.value(
ValueMap.builder("").put("s@dir/otherdir/thirddir", "rai minecraft").put("m@www.raiminecraft.com", "minecraft").build());
ValueMap.builder("").put("s@dir/otherdir/thirddir", "rai minecraft").put("m@www.raiminecraft.com", "minecraft").build());

@SerializedName("cool.awesome@list[]neat")
public final TrackedValue<ValueList<String>> awesomeList = this.value(
ValueList.create("", "gkjasdkjfghsa^&%^&...gsd"));
ValueList.create("", "gkjasdkjfghsa^&%^&...gsd"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class TestReflectiveConfig extends ReflectiveConfig {
public final TrackedValue<Integer> b = this.value(1);
public final TrackedValue<Integer> c = this.value(2);

@IntegerRange(min=0, max=10)
@IntegerRange(min = 0, max = 10)
public final TrackedValue<Integer> d = this.value(3);
@SerializedName("custom_serialized_name_vec")
@Alias("boring_name_vec")
Expand Down Expand Up @@ -87,7 +87,7 @@ public final class TestReflectiveConfig extends ReflectiveConfig {

public final TrackedValue<ValueMap<ValueList<String>>> key_binds = this.map(ValueList.create("")).build();

@IntegerRange(min=0, max=10)
@IntegerRange(min = 0, max = 10)
public final TrackedValue<ValueList<Integer>> ints = this.list(0, 1, 2, 3, 4);

public final TrackedValue<ValueList<ValueMap<Integer>>> listOfNestedObjects = this.list(ValueMap.builder(0).build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public final class TestValueConfig3 extends ReflectiveConfig {
public final TrackedValue<Integer> a = this.value(0);
public final TrackedValue<Integer> b = this.value(1);
public final TrackedValue<Integer> c = this.value(2);
@FloatRange(min=0, max=10)
@FloatRange(min = 0, max = 10)
public final TrackedValue<Integer> d = this.value(3);
public final TrackedValue<Vec3i> vec = this.value(new Vec3i(100, 200, 300));
public final TrackedValue<String> whatever = this.value("Riesling");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class TestValueConfig4 extends ReflectiveConfig {
public final TrackedValue<Integer> b = this.value(1);
public final TrackedValue<Integer> c = this.value(2);

@IntegerRange(min=0, max=10)
@IntegerRange(min = 0, max = 10)
public final TrackedValue<Integer> d = this.value(3);
public final TrackedValue<Vec3i> vec = this.value(new Vec3i(100, 200, 300));

Expand All @@ -55,7 +55,7 @@ public final class TestValueConfig4 extends ReflectiveConfig {
@Comment("Test section comment 4")
public final Nested nested4 = new Nested();

@IntegerRange(min=0, max=10)
@IntegerRange(min = 0, max = 10)
public final TrackedValue<ValueList<Integer>> ints = this.list(0, 1, 2, 3, 4);

public final TrackedValue<ValueList<ValueMap<Integer>>> listOfNestedObjects = this.list(ValueMap.builder(0).build(),
Expand Down

0 comments on commit 952cb33

Please sign in to comment.