Fix minor Checkstyle violations

- Mostly missing JavaDoc, some line lengths
This commit is contained in:
ljacqu
2018-03-11 19:08:21 +01:00
parent 98bd0f7a6b
commit fddb3bf265
23 changed files with 142 additions and 48 deletions
@@ -11,6 +11,7 @@ import java.util.Objects;
/**
* Custom matchers for AuthMe entities.
*/
@SuppressWarnings("checkstyle:JavadocMethod") // Justification: Javadoc would be huge because of the many parameters
public final class AuthMeMatchers {
private AuthMeMatchers() {
@@ -67,7 +67,7 @@ public class ClassCollector {
public List<Class<?>> collectClasses(Predicate<Class<?>> filter) {
File rootFolder = new File(root);
List<Class<?>> collection = new ArrayList<>();
collectClasses(rootFolder, filter, collection);
gatherClassesFromFile(rootFolder, filter, collection);
return collection;
}
@@ -124,14 +124,14 @@ public class ClassCollector {
* @param filter the class predicate
* @param collection collection to add classes to
*/
private void collectClasses(File folder, Predicate<Class<?>> filter, List<Class<?>> collection) {
private void gatherClassesFromFile(File folder, Predicate<Class<?>> filter, List<Class<?>> collection) {
File[] files = folder.listFiles();
if (files == null) {
throw new IllegalStateException("Could not read files from '" + folder + "'");
}
for (File file : files) {
if (file.isDirectory()) {
collectClasses(file, filter, collection);
gatherClassesFromFile(file, filter, collection);
} else if (file.isFile()) {
Class<?> clazz = loadTaskClassFromFile(file);
if (clazz != null && filter.test(clazz)) {
@@ -82,7 +82,6 @@ public final class ReflectionTestUtils {
* @param clazz the class to retrieve a method from
* @param methodName the name of the method
* @param parameterTypes the parameter types the method to retrieve has
*
* @return the method of the class, set to be accessible
*/
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
@@ -96,6 +95,15 @@ public final class ReflectionTestUtils {
}
}
/**
* Invokes the given method on the provided instance with the given parameters.
*
* @param method the method to invoke
* @param instance the instance to invoke the method on (null for static methods)
* @param parameters the parameters to pass to the method
* @param <V> return value of the method
* @return method return value
*/
@SuppressWarnings("unchecked")
public static <V> V invokeMethod(Method method, Object instance, Object... parameters) {
method.setAccessible(true);
@@ -14,6 +14,7 @@ import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
/**
* Contains matchers for LimboPlayer.
*/
@SuppressWarnings("checkstyle:JavadocMethod") // Justification: Javadoc would be huge because of the many parameters
public final class LimboPlayerMatchers {
private LimboPlayerMatchers() {
@@ -45,7 +46,8 @@ public final class LimboPlayerMatchers {
@Override
public void describeMismatchSafely(LimboPlayer item, Description description) {
description.appendText(format("Limbo with isOp=%s, groups={%s}, canFly=%s, walkSpeed=%f, flySpeed=%f",
item.isOperator(), String.join(" ,", item.getGroups()), item.isCanFly(), item.getWalkSpeed(), item.getFlySpeed()));
item.isOperator(), String.join(" ,", item.getGroups()), item.isCanFly(),
item.getWalkSpeed(), item.getFlySpeed()));
}
};
}
@@ -27,6 +27,15 @@ public final class SqlDataSourceTestUtil {
return new MySQL(settings, hikariDataSource, extensionsFactory);
}
/**
* Creates a SQLite implementation for testing purposes. Methods are overridden so the
* provided connection is never overridden.
*
* @param settings settings instance
* @param dataFolder data folder
* @param connection connection to use
* @return the created SQLite instance
*/
public static SQLite createSqlite(Settings settings, File dataFolder, Connection connection) {
return new SQLite(settings, dataFolder, connection) {
// Override reload() so it doesn't run SQLite#connect, since we're given a specific Connection to use