Begin implementation of CheckStyle style checking

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2019-04-23 14:00:20 +10:00
parent 30a442aef7
commit c240b58f66
88 changed files with 246 additions and 192 deletions

36
paper-api/checkstyle.xml Normal file
View File

@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<!-- See http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- See http://checkstyle.sourceforge.net/config_whitespace.html -->
<module name="FileTabCharacter"/>
<!-- See http://checkstyle.sourceforge.net/config_misc.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<module name="TreeWalker">
<!-- See http://checkstyle.sourceforge.net/config_import.html -->
<module name="RedundantImport"/>
<!-- See http://checkstyle.sourceforge.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<!-- See http://checkstyle.sourceforge.net/config_design.html -->
<module name="FinalClass"/>
<module name="InterfaceIsType"/>
<!-- See http://checkstyle.sourceforge.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="UpperEll"/>
</module>
</module>

View File

@ -164,6 +164,30 @@
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.19</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>

View File

@ -114,8 +114,8 @@ public enum ChatColor {
private final char code;
private final boolean isFormat;
private final String toString;
private final static Map<Integer, ChatColor> BY_ID = Maps.newHashMap();
private final static Map<Character, ChatColor> BY_CHAR = Maps.newHashMap();
private static final Map<Integer, ChatColor> BY_ID = Maps.newHashMap();
private static final Map<Character, ChatColor> BY_CHAR = Maps.newHashMap();
private ChatColor(char code, int intCode) {
this(code, intCode, false);

View File

@ -13,7 +13,7 @@ public enum CoalType {
CHARCOAL(0x1);
private final byte data;
private final static Map<Byte, CoalType> BY_DATA = Maps.newHashMap();
private static final Map<Byte, CoalType> BY_DATA = Maps.newHashMap();
private CoalType(final int data) {
this.data = (byte) data;

View File

@ -44,7 +44,7 @@ public enum CropState {
RIPE(0x7);
private final byte data;
private final static Map<Byte, CropState> BY_DATA = Maps.newHashMap();
private static final Map<Byte, CropState> BY_DATA = Maps.newHashMap();
private CropState(final int data) {
this.data = (byte) data;

View File

@ -35,7 +35,7 @@ public enum Difficulty {
HARD(3);
private final int value;
private final static Map<Integer, Difficulty> BY_ID = Maps.newHashMap();
private static final Map<Integer, Difficulty> BY_ID = Maps.newHashMap();
private Difficulty(final int value) {
this.value = value;

View File

@ -80,10 +80,10 @@ public enum DyeColor {
private final byte dyeData;
private final Color color;
private final Color firework;
private final static DyeColor[] BY_WOOL_DATA;
private final static DyeColor[] BY_DYE_DATA;
private final static Map<Color, DyeColor> BY_COLOR;
private final static Map<Color, DyeColor> BY_FIREWORK;
private static final DyeColor[] BY_WOOL_DATA;
private static final DyeColor[] BY_DYE_DATA;
private static final Map<Color, DyeColor> BY_COLOR;
private static final Map<Color, DyeColor> BY_FIREWORK;
private DyeColor(final int woolData, final int dyeData, /*@NotNull*/ Color color, /*@NotNull*/ Color firework) {
this.woolData = (byte) woolData;

View File

@ -153,7 +153,7 @@ public enum EntityEffect {
private final byte data;
private final Class<? extends Entity> applicable;
private final static Map<Byte, EntityEffect> BY_DATA = Maps.newHashMap();
private static final Map<Byte, EntityEffect> BY_DATA = Maps.newHashMap();
EntityEffect(final int data, /*@NotNull*/ Class<? extends Entity> clazz) {
this.data = (byte) data;

View File

@ -36,7 +36,7 @@ public enum GameMode {
SPECTATOR(3);
private final int value;
private final static Map<Integer, GameMode> BY_ID = Maps.newHashMap();
private static final Map<Integer, GameMode> BY_ID = Maps.newHashMap();
private GameMode(final int value) {
this.value = value;

View File

@ -24,7 +24,7 @@ public enum GrassSpecies {
FERN_LIKE(0x2);
private final byte data;
private final static Map<Byte, GrassSpecies> BY_DATA = Maps.newHashMap();
private static final Map<Byte, GrassSpecies> BY_DATA = Maps.newHashMap();
private GrassSpecies(final int data) {
this.data = (byte) data;

View File

@ -78,7 +78,7 @@ public enum Instrument {
PLING(0xF);
private final byte type;
private final static Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
private static final Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
private Instrument(final int type) {
this.type = (byte) type;

View File

@ -3243,7 +3243,7 @@ public enum Material implements Keyed {
private final int id;
private final Constructor<? extends MaterialData> ctor;
private final static Map<String, Material> BY_NAME = Maps.newHashMap();
private static final Map<String, Material> BY_NAME = Maps.newHashMap();
private final int maxStack;
private final short durability;
public final Class<?> data;

View File

@ -126,7 +126,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
@Nullable
T get(@NotNull NamespacedKey key);
final static class SimpleRegistry<T extends Enum<T> & Keyed> implements Registry<T> {
static final class SimpleRegistry<T extends Enum<T> & Keyed> implements Registry<T> {
private final Map<NamespacedKey, T> map;

View File

@ -14,7 +14,7 @@ public enum SandstoneType {
SMOOTH(0x2);
private final byte data;
private final static Map<Byte, SandstoneType> BY_DATA = Maps.newHashMap();
private static final Map<Byte, SandstoneType> BY_DATA = Maps.newHashMap();
private SandstoneType(final int data) {
this.data = (byte) data;

View File

@ -20,7 +20,7 @@ import java.util.Objects;
* The registration of new {@link StructureType}s is case-sensitive.
*/
// Order is retrieved from WorldGenFactory
public class StructureType {
public final class StructureType {
private static final Map<String, StructureType> structureTypeMap = new HashMap<>();

View File

@ -37,7 +37,7 @@ public enum TreeSpecies {
;
private final byte data;
private final static Map<Byte, TreeSpecies> BY_DATA = Maps.newHashMap();
private static final Map<Byte, TreeSpecies> BY_DATA = Maps.newHashMap();
private TreeSpecies(final int data) {
this.data = (byte) data;

View File

@ -18,7 +18,7 @@ public enum WorldType {
CUSTOMIZED("CUSTOMIZED"),
BUFFET("BUFFET");
private final static Map<String, WorldType> BY_NAME = Maps.newHashMap();
private static final Map<String, WorldType> BY_NAME = Maps.newHashMap();
private final String name;
private WorldType(/*@NotNull*/ String name) {

View File

@ -10,7 +10,7 @@ import java.util.Comparator;
* All topics are listed in alphabetic order, but topics that start with a
* slash come after topics that don't.
*/
public class HelpTopicComparator implements Comparator<HelpTopic> {
public final class HelpTopicComparator implements Comparator<HelpTopic> {
// Singleton implementations
private static final TopicNameComparator tnc = new TopicNameComparator();
@ -31,7 +31,7 @@ public class HelpTopicComparator implements Comparator<HelpTopic> {
return tnc.compare(lhs.getName(), rhs.getName());
}
public static class TopicNameComparator implements Comparator<String> {
public static final class TopicNameComparator implements Comparator<String> {
private TopicNameComparator(){}
public int compare(@NotNull String lhs, @NotNull String rhs) {

View File

@ -15,7 +15,7 @@ import org.jetbrains.annotations.Nullable;
* as it should.
*/
public abstract class InventoryView {
public final static int OUTSIDE = -999;
public static final int OUTSIDE = -999;
/**
* Represents various extra properties of certain inventory windows.
*/

View File

@ -34,7 +34,7 @@ public abstract class MapRenderer {
*
* @return True if contextual, false otherwise.
*/
final public boolean isContextual() {
public final boolean isContextual() {
return contextual;
}
@ -52,6 +52,6 @@ public abstract class MapRenderer {
* @param canvas The canvas to use for rendering.
* @param player The player who triggered the rendering.
*/
abstract public void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player player);
public abstract void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player player);
}

View File

@ -66,8 +66,8 @@ public enum MushroomBlockTexture {
* Stem texture on all faces.
*/
ALL_STEM(15, null);
private final static Map<Byte, MushroomBlockTexture> BY_DATA = Maps.newHashMap();
private final static Map<BlockFace, MushroomBlockTexture> BY_BLOCKFACE = Maps.newHashMap();
private static final Map<Byte, MushroomBlockTexture> BY_DATA = Maps.newHashMap();
private static final Map<BlockFace, MushroomBlockTexture> BY_BLOCKFACE = Maps.newHashMap();
private final Byte data;
private final BlockFace capFace;

View File

@ -16,7 +16,7 @@ public enum PermissionDefault {
NOT_OP("!op", "notop", "!operator", "notoperator", "!admin", "notadmin");
private final String[] names;
private final static Map<String, PermissionDefault> lookup = new HashMap<String, PermissionDefault>();
private static final Map<String, PermissionDefault> lookup = new HashMap<String, PermissionDefault>();
private PermissionDefault(/*@NotNull*/ String... names) {
this.names = names;

View File

@ -3,18 +3,12 @@ package org.bukkit.scoreboard;
/**
* Criteria names which trigger an objective to be modified by actions in-game
*/
public class Criterias {
public static final String HEALTH;
public static final String PLAYER_KILLS;
public static final String TOTAL_KILLS;
public static final String DEATHS;
public final class Criterias {
static {
HEALTH="health";
PLAYER_KILLS="playerKillCount";
TOTAL_KILLS="totalKillCount";
DEATHS="deathCount";
}
public static final String HEALTH = "health";
public static final String PLAYER_KILLS = "playerKillCount";
public static final String TOTAL_KILLS = "totalKillCount";
public static final String DEATHS = "deathCount";
private Criterias() {}
}

View File

@ -9,7 +9,7 @@ import org.bukkit.configuration.serialization.ConfigurationSerialization;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;
class Wrapper<T extends Map<String, ?> & Serializable> implements Serializable {
final class Wrapper<T extends Map<String, ?> & Serializable> implements Serializable {
private static final long serialVersionUID = -986209235411767547L;
final T map;

View File

@ -4,7 +4,7 @@ package org.bukkit.util.noise;
* Base class for all noise generators
*/
public abstract class NoiseGenerator {
protected final int perm[] = new int[512];
protected final int[] perm= new int[512];
protected double offsetX;
protected double offsetY;
protected double offsetZ;

View File

@ -11,13 +11,13 @@ import org.jetbrains.annotations.NotNull;
* different results
*/
public class PerlinNoiseGenerator extends NoiseGenerator {
protected static final int grad3[][] = {{1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0},
protected static final int[][] grad3 = {{1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0},
{1, 0, 1}, {-1, 0, 1}, {1, 0, -1}, {-1, 0, -1},
{0, 1, 1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}};
private static final PerlinNoiseGenerator instance = new PerlinNoiseGenerator();
protected PerlinNoiseGenerator() {
int p[] = {151, 160, 137, 91, 90, 15, 131, 13, 201,
int[] p = {151, 160, 137, 91, 90, 15, 131, 13, 201,
95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37,
240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62,
94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56,

View File

@ -25,7 +25,7 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator {
protected static final double G42 = G4 * 2.0;
protected static final double G43 = G4 * 3.0;
protected static final double G44 = G4 * 4.0 - 1.0;
protected static final int grad4[][] = {{0, 1, 1, 1}, {0, 1, 1, -1}, {0, 1, -1, 1}, {0, 1, -1, -1},
protected static final int[][] grad4 = {{0, 1, 1, 1}, {0, 1, 1, -1}, {0, 1, -1, 1}, {0, 1, -1, -1},
{0, -1, 1, 1}, {0, -1, 1, -1}, {0, -1, -1, 1}, {0, -1, -1, -1},
{1, 0, 1, 1}, {1, 0, 1, -1}, {1, 0, -1, 1}, {1, 0, -1, -1},
{-1, 0, 1, 1}, {-1, 0, 1, -1}, {-1, 0, -1, 1}, {-1, 0, -1, -1},
@ -33,7 +33,7 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator {
{-1, 1, 0, 1}, {-1, 1, 0, -1}, {-1, -1, 0, 1}, {-1, -1, 0, -1},
{1, 1, 1, 0}, {1, 1, -1, 0}, {1, -1, 1, 0}, {1, -1, -1, 0},
{-1, 1, 1, 0}, {-1, 1, -1, 0}, {-1, -1, 1, 0}, {-1, -1, -1, 0}};
protected static final int simplex[][] = {
protected static final int[][] simplex = {
{0, 1, 2, 3}, {0, 1, 3, 2}, {0, 0, 0, 0}, {0, 2, 3, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 2, 3, 0},
{0, 2, 1, 3}, {0, 0, 0, 0}, {0, 3, 1, 2}, {0, 3, 2, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 3, 2, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},

View File

@ -41,7 +41,7 @@ public class LocationTest {
@Parameters(name= "{index}: {0}")
public static List<Object[]> data() {
Random RANDOM = new Random(1l); // Test is deterministic
Random RANDOM = new Random(1L); // Test is deterministic
int r = 0;
return ImmutableList.<Object[]>of(
new Object[] { "X",

View File

@ -12,7 +12,7 @@ import org.bukkit.plugin.SimplePluginManager;
import com.google.common.collect.ImmutableMap;
public class TestServer implements InvocationHandler {
public final class TestServer implements InvocationHandler {
private static interface MethodHandler {
Object handle(TestServer server, Object[] args);
}

View File

@ -428,7 +428,7 @@ public abstract class ConfigurationSectionTest {
assertEquals(Arrays.asList((Object) true, false), section.getBooleanList(key));
assertEquals(Arrays.asList((Object) 4.0, 5.0, 6.0), section.getDoubleList(key));
assertEquals(Arrays.asList((Object) 4.0f, 5.0f, 6.0f), section.getFloatList(key));
assertEquals(Arrays.asList((Object) 4l, 5l, 6l), section.getLongList(key));
assertEquals(Arrays.asList((Object) 4L, 5L, 6L), section.getLongList(key));
assertEquals(Arrays.asList((Object) (byte) 4, (byte) 5, (byte) 6), section.getByteList(key));
assertEquals(Arrays.asList((Object) (short) 4, (short) 5, (short) 6), section.getShortList(key));
assertEquals(map, section.getMapList(key).get(0));

View File

@ -30,7 +30,7 @@ public class SyntheticEventTest {
Assert.assertEquals(1, impl.callCount);
}
public static abstract class Base<E extends Event> implements Listener {
public abstract static class Base<E extends Event> implements Listener {
int callCount = 0;
public void accept(E evt) {

View File

@ -13,7 +13,7 @@ import org.bukkit.generator.ChunkGenerator;
public class TestPlugin extends PluginBase {
private boolean enabled = true;
final private String pluginName;
private final String pluginName;
public TestPlugin(String pluginName) {
this.pluginName = pluginName;

View File

@ -9,7 +9,7 @@ import java.util.HashMap;
import org.bukkit.entity.Player;
public class TestPlayer implements InvocationHandler {
public final class TestPlayer implements InvocationHandler {
private static interface MethodHandler {
Object handle(TestPlayer server, Object[] args);
}