Add additional checkstyle checks

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2020-01-24 17:37:30 +11:00
parent 78e6909f8c
commit 0c53c95293
35 changed files with 227 additions and 202 deletions

View File

@@ -50,9 +50,34 @@
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<!-- See https://checkstyle.org/config_whitespace.html -->
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoLineWrap"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore">
<property name="allowLineBreaks" value="true"/>
</module>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="SingleSpaceSeparator"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
<property name="allowEmptyCatches" value="true"/>
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
</module>
<!-- See http://checkstyle.sourceforge.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<!-- See https://checkstyle.org/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<!-- See http://checkstyle.sourceforge.net/config_design.html -->
<module name="FinalClass"/>
<module name="InterfaceIsType"/>

View File

@@ -73,8 +73,9 @@ public class TimingsCommand extends BukkitCommand {
if (separate) {
fileNames.println(pluginIdx + " " + plugin.getDescription().getFullName());
fileTimings.println("Plugin " + pluginIdx);
} else {
fileTimings.println(plugin.getDescription().getFullName());
}
else fileTimings.println(plugin.getDescription().getFullName());
for (RegisteredListener listener : HandlerList.getRegisteredListeners(plugin)) {
if (listener instanceof TimedRegisteredListener) {
TimedRegisteredListener trl = (TimedRegisteredListener) listener;

View File

@@ -826,10 +826,10 @@ public class MemorySection implements ConfigurationSection {
}
protected boolean isPrimitiveWrapper(@Nullable Object input) {
return input instanceof Integer || input instanceof Boolean ||
input instanceof Character || input instanceof Byte ||
input instanceof Short || input instanceof Double ||
input instanceof Long || input instanceof Float;
return input instanceof Integer || input instanceof Boolean
|| input instanceof Character || input instanceof Byte
|| input instanceof Short || input instanceof Double
|| input instanceof Long || input instanceof Float;
}
@Nullable

View File

@@ -9,6 +9,7 @@ public class MinecraftFont extends MapFont {
private static final int spaceSize = 2;
// CHECKSTYLE:OFF
private static final String fontChars =
" !\"#$%&'()*+,-./0123456789:;<=>?" +
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" +
@@ -278,6 +279,7 @@ public class MinecraftFont extends MapFont {
/* 254 */ {0,0,60,60,60,60,0,0},
/* 255 */ {0,0,0,0,0,0,0,0},
};
// CHECKSTYLE:ON
/**
* A static non-malleable MinecraftFont.

View File

@@ -49,7 +49,7 @@ import org.yaml.snakeyaml.error.YAMLException;
*/
public final class JavaPluginLoader implements PluginLoader {
final Server server;
private final Pattern[] fileFilters = new Pattern[] { Pattern.compile("\\.jar$"), };
private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
@@ -288,8 +288,7 @@ public final class JavaPluginLoader implements PluginLoader {
plugin.getLogger().log(
Level.WARNING,
String.format(
"\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated." +
" \"%s\"; please notify the authors %s.",
"\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated. \"%s\"; please notify the authors %s.",
plugin.getDescription().getFullName(),
clazz.getName(),
method.toGenericString(),

View File

@@ -1,3 +1,4 @@
// CHECKSTYLE:OFF
package org.bukkit.util.noise;
import java.util.Random;

View File

@@ -22,23 +22,23 @@ public class YamlConfigurationTest extends FileConfigurationTest {
@Override
public String getTestValuesString() {
return "integer: -2147483648\n" +
"string: String Value\n" +
"long: 9223372036854775807\n" +
"true-boolean: true\n" +
"false-boolean: false\n" +
"vector:\n" +
" ==: Vector\n" +
" x: 12345.67\n" +
" y: 64.0\n" +
" z: -12345.6789\n" +
"list:\n" +
"- 1\n" +
"- 2\n" +
"- 3\n" +
"- 4\n" +
"- 5\n" +
"'42': The Answer\n";
return "integer: -2147483648\n"
+ "string: String Value\n"
+ "long: 9223372036854775807\n"
+ "true-boolean: true\n"
+ "false-boolean: false\n"
+ "vector:\n"
+ " ==: Vector\n"
+ " x: 12345.67\n"
+ " y: 64.0\n"
+ " z: -12345.6789\n"
+ "list:\n"
+ "- 1\n"
+ "- 2\n"
+ "- 3\n"
+ "- 4\n"
+ "- 5\n"
+ "'42': The Answer\n";
}
@Test

View File

@@ -25,8 +25,7 @@ import org.junit.Test;
public class MaterialDataTest {
@Test
public void testDoor()
{
public void testDoor() {
@SuppressWarnings("deprecation")
Door door = new Door();
assertThat("Constructed with default door type", door.getItemType(), equalTo(Material.LEGACY_WOODEN_DOOR));
@@ -41,19 +40,16 @@ public class MaterialDataTest {
BlockFace[] directions = new BlockFace[]{BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH};
boolean[] openStates = new boolean[]{false, true};
boolean[] hingeStates = new boolean[]{false, true};
for(Material type : types)
{
for (Material type : types) {
// Test bottom half
for(BlockFace facing : directions)
{
for (BlockFace facing : directions) {
door = new Door(type, facing);
assertThat("Constructed with correct door type", door.getItemType(), equalTo(type));
assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(false));
assertThat("Constructed with correct direction", door.getFacing(), equalTo(facing));
assertThat("Constructed with default open state", door.isOpen(), equalTo(false));
for(boolean openState : openStates)
{
for (boolean openState : openStates) {
door = new Door(type, facing, openState);
assertThat("Constructed with correct door type", door.getItemType(), equalTo(type));
assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(false));
@@ -63,8 +59,7 @@ public class MaterialDataTest {
}
// Test top half
for(boolean hingeState : hingeStates)
{
for (boolean hingeState : hingeStates) {
door = new Door(type, hingeState);
assertThat("Constructed with correct door type", door.getItemType(), equalTo(type));
assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(true));

View File

@@ -71,7 +71,9 @@ public class PluginManagerTest {
} catch (Throwable ex) {
store.value = ex;
}
}});
}
}
);
secondThread.start();
secondThread.join();
if (store.value != null) {

View File

@@ -38,7 +38,7 @@ public class StringUtilTest {
@Test
public void copyTokenTest() {
String token = "ab";
Iterable<String> original = ImmutableList.of("ab12", "aC561", "AB5195", "Ab76", "", "a");
List<String> original = ImmutableList.of("ab12", "aC561", "AB5195", "Ab76", "", "a");
List<String> expected = ImmutableList.of("ab12", "AB5195", "Ab76");
List<String> list = new ArrayList<String>();
assertThat(StringUtil.copyPartialMatches(token, original, list), is(expected));