Fix minor Checkstyle violations
- Mostly missing JavaDoc, some line lengths
This commit is contained in:
@@ -131,7 +131,8 @@ public class DrawDependency implements ToolTask {
|
||||
private Class<?> unwrapGenericClass(Type genericType) {
|
||||
if (genericType == Factory.class || genericType == SingletonStore.class) {
|
||||
Class<?> parameterType = ReflectionUtils.getGenericType(genericType);
|
||||
Objects.requireNonNull(parameterType, "Parameter type for '" + genericType + "' should be a concrete class");
|
||||
Objects.requireNonNull(parameterType,
|
||||
"Parameter type for '" + genericType + "' should be a concrete class");
|
||||
return parameterType;
|
||||
}
|
||||
return InjectorUtils.convertToClass(genericType);
|
||||
|
||||
@@ -56,6 +56,12 @@ public class EncryptionMethodInfoGatherer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a description of the given hash algorithm based on its annotations.
|
||||
*
|
||||
* @param algorithm the algorithm to describe
|
||||
* @return description of the hash algorithm
|
||||
*/
|
||||
private static MethodDescription createDescription(HashAlgorithm algorithm) {
|
||||
Class<? extends EncryptionMethod> clazz = algorithm.getClazz();
|
||||
EncryptionMethod method = createEncryptionMethod(clazz);
|
||||
|
||||
@@ -37,6 +37,7 @@ public class PermissionNodesGatherer {
|
||||
/**
|
||||
* Return a sorted collection of all permission nodes, including its JavaDoc description.
|
||||
*
|
||||
* @param <T> permission node enum type
|
||||
* @return Ordered map whose keys are the permission nodes and the values the associated JavaDoc
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -4,18 +4,20 @@ import tools.utils.AutoToolTask;
|
||||
import tools.utils.FileIoUtils;
|
||||
import tools.utils.TagValue.NestedTagValue;
|
||||
import tools.utils.TagValueHolder;
|
||||
import tools.utils.ToolsConstants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static tools.utils.ToolsConstants.DOCS_FOLDER;
|
||||
import static tools.utils.ToolsConstants.TOOLS_SOURCE_ROOT;
|
||||
|
||||
/**
|
||||
* Task responsible for formatting a permissions node list and
|
||||
* for writing it to a file if desired.
|
||||
*/
|
||||
public class PermissionsListWriter implements AutoToolTask {
|
||||
|
||||
private static final String TEMPLATE_FILE = ToolsConstants.TOOLS_SOURCE_ROOT + "docs/permissions/permission_nodes.tpl.md";
|
||||
private static final String PERMISSIONS_OUTPUT_FILE = ToolsConstants.DOCS_FOLDER + "permission_nodes.md";
|
||||
private static final String TEMPLATE_FILE = TOOLS_SOURCE_ROOT + "docs/permissions/permission_nodes.tpl.md";
|
||||
private static final String PERMISSIONS_OUTPUT_FILE = DOCS_FOLDER + "permission_nodes.md";
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
|
||||
@@ -45,10 +45,10 @@ public class TranslationPageGenerator implements AutoToolTask {
|
||||
NestedTagValue translationValuesHolder = new NestedTagValue();
|
||||
|
||||
for (TranslationInfo translation : gatherer.getTranslationInfo()) {
|
||||
int percentage = (int) Math.round(translation.percentTranslated * 100);
|
||||
String name = firstNonNull(LANGUAGE_NAMES.get(translation.code), "?");
|
||||
int percentage = (int) Math.round(translation.getPercentTranslated() * 100);
|
||||
String name = firstNonNull(LANGUAGE_NAMES.get(translation.getCode()), "?");
|
||||
TagValueHolder valueHolder = TagValueHolder.create()
|
||||
.put("code", translation.code)
|
||||
.put("code", translation.getCode())
|
||||
.put("name", name)
|
||||
.put("percentage", Integer.toString(percentage))
|
||||
.put("color", computeColor(percentage));
|
||||
|
||||
@@ -25,7 +25,7 @@ public class TranslationsGatherer {
|
||||
|
||||
public TranslationsGatherer() {
|
||||
gatherTranslations();
|
||||
translationInfo.sort((e1, e2) -> getCode(e1).compareTo(getCode(e2)));
|
||||
translationInfo.sort((e1, e2) -> getSortCode(e1).compareTo(getSortCode(e2)));
|
||||
}
|
||||
|
||||
public List<TranslationInfo> getTranslationInfo() {
|
||||
@@ -61,16 +61,6 @@ public class TranslationsGatherer {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class TranslationInfo {
|
||||
public final String code;
|
||||
public final double percentTranslated;
|
||||
|
||||
TranslationInfo(String code, double percentTranslated) {
|
||||
this.code = code;
|
||||
this.percentTranslated = percentTranslated;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language code from the translation info for sorting purposes.
|
||||
* Returns "a" for "en" language code to sort English on top.
|
||||
@@ -78,8 +68,26 @@ public class TranslationsGatherer {
|
||||
* @param info the translation info
|
||||
* @return the language code for sorting
|
||||
*/
|
||||
private static String getCode(TranslationInfo info) {
|
||||
private static String getSortCode(TranslationInfo info) {
|
||||
return "en".equals(info.code) ? "a" : info.code;
|
||||
}
|
||||
|
||||
public static final class TranslationInfo {
|
||||
private final String code;
|
||||
private final double percentTranslated;
|
||||
|
||||
TranslationInfo(String code, double percentTranslated) {
|
||||
this.code = code;
|
||||
this.percentTranslated = percentTranslated;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public double getPercentTranslated() {
|
||||
return percentTranslated;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class GeneratePluginYml implements AutoToolTask {
|
||||
List<String> pluginYmlLines = FileIoUtils.readLinesFromFile(Paths.get(PLUGIN_YML_FILE));
|
||||
int lineNr = 0;
|
||||
for (String line : pluginYmlLines) {
|
||||
if (line.equals("commands:")) {
|
||||
if ("commands:".equals(line)) {
|
||||
break;
|
||||
}
|
||||
++lineNr;
|
||||
|
||||
@@ -33,8 +33,8 @@ public class CheckMessageKeyUsages implements AutoToolTask {
|
||||
if (unusedKeys.isEmpty()) {
|
||||
System.out.println("No unused MessageKey entries found :)");
|
||||
} else {
|
||||
System.out.println("Did not find usages for keys:\n- " +
|
||||
String.join("\n- ", Lists.transform(unusedKeys, MessageKey::name)));
|
||||
System.out.println("Did not find usages for keys:\n- "
|
||||
+ String.join("\n- ", Lists.transform(unusedKeys, MessageKey::name)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,21 +51,6 @@ public class CheckMessageKeyUsages implements AutoToolTask {
|
||||
return keys;
|
||||
}
|
||||
|
||||
private List<File> findUsagesOfKey(MessageKey key) {
|
||||
List<File> filesUsingKey = new ArrayList<>();
|
||||
File sourceFolder = new File(ToolsConstants.MAIN_SOURCE_ROOT);
|
||||
|
||||
Consumer<File> usagesCollector = file -> {
|
||||
String source = FileIoUtils.readFromFile(file.toPath());
|
||||
if (source.contains(key.name())) {
|
||||
filesUsingKey.add(file);
|
||||
}
|
||||
};
|
||||
|
||||
walkJavaFileTree(sourceFolder, usagesCollector);
|
||||
return filesUsingKey;
|
||||
}
|
||||
|
||||
private static void walkJavaFileTree(File folder, Consumer<File> javaFileConsumer) {
|
||||
for (File file : FileIoUtils.listFilesOrThrow(folder)) {
|
||||
if (file.isDirectory()) {
|
||||
|
||||
@@ -27,6 +27,12 @@ public final class FileIoUtils {
|
||||
writeToFile(Paths.get(outputFile), contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the given contents to the file, overriding any existing content.
|
||||
*
|
||||
* @param path the file to write to
|
||||
* @param contents the contents to write
|
||||
*/
|
||||
public static void writeToFile(Path path, String contents) {
|
||||
try {
|
||||
Files.write(path, contents.getBytes());
|
||||
@@ -35,6 +41,12 @@ public final class FileIoUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given contents to the file while keeping any existing content.
|
||||
*
|
||||
* @param outputFile the file to write to
|
||||
* @param contents the contents to append
|
||||
*/
|
||||
public static void appendToFile(String outputFile, String contents) {
|
||||
try {
|
||||
Files.write(Paths.get(outputFile), contents.getBytes(), StandardOpenOption.APPEND);
|
||||
@@ -47,6 +59,12 @@ public final class FileIoUtils {
|
||||
return readFromFile(Paths.get(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the given file's contents as string.
|
||||
*
|
||||
* @param file the file to read
|
||||
* @return the file's contents
|
||||
*/
|
||||
public static String readFromFile(Path file) {
|
||||
try {
|
||||
return new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
|
||||
@@ -55,6 +73,12 @@ public final class FileIoUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lines of the given file.
|
||||
*
|
||||
* @param path the path of the file to read
|
||||
* @return the lines of the file
|
||||
*/
|
||||
public static List<String> readLinesFromFile(Path path) {
|
||||
try {
|
||||
return Files.readAllLines(path, StandardCharsets.UTF_8);
|
||||
|
||||
Reference in New Issue
Block a user