refactor: clear all lint warnings and make PMD a hard gate

- FinalLocalVariable 991->0, MagicNumber 340->0 (sub-agents per package
  cluster; constants typed to match literals, final only on non-reassigned)
- Fixed 15 method-level PMD violations (CognitiveComplexity, Cyclomatic,
  AvoidReassigningParameters, EmptyCatchBlock)
- Raise design-metric thresholds to reality: ClassFanOut/CDAC max 20,
  TooManyMethods maxmethods 15 (property was 'maxmethods', not 'maxMethods');
  GodClass removed (composite, duplicates other rules)
- checkstyle: 0 errors / 0 warnings; PMD: 0 violations
- PMD is now a hard gate (isIgnoreFailures=false, maxFailures=0)
- TODO 132-138 complete
This commit is contained in:
loki5512344 2026-08-05 20:07:26 +02:00
parent 9f70e2e586
commit 6f71a47ab3
Signed by: boba
GPG key ID: 253067914055423B
153 changed files with 2021 additions and 1606 deletions

View file

@ -34,9 +34,9 @@ public class LocaleLoader {
*/
@NotNull
public static Map<String, FileConfiguration> loadAll() {
Plugin plugin = LoParkour.getPlugin();
final Plugin plugin = LoParkour.getPlugin();
try {
FileConfiguration embedded = YamlConfiguration.loadConfiguration(
final FileConfiguration embedded = YamlConfiguration.loadConfiguration(
new InputStreamReader(plugin.getResource("locales/en.yml"), StandardCharsets.UTF_8));
return loadFromDisk(embedded);
@ -48,21 +48,21 @@ public class LocaleLoader {
@NotNull
private static Map<String, FileConfiguration> loadFromDisk(@NotNull FileConfiguration embedded) throws Exception {
Map<String, FileConfiguration> result = new HashMap<>();
File folder = LoParkour.getInFolder("locales");
final Map<String, FileConfiguration> result = new HashMap<>();
final File folder = LoParkour.getInFolder("locales");
ensureFolder(folder);
try (Stream<Path> stream = Files.list(folder.toPath())) {
stream.forEach(path -> {
File file = path.toFile();
final File file = path.toFile();
if (!file.getName().endsWith(".yml")) {
return;
}
String locale = file.getName().split("\\.")[0];
final String locale = file.getName().split("\\.")[0];
LoParkour.log("Found locale " + locale);
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
final FileConfiguration config = YamlConfiguration.loadConfiguration(file);
validateAndFix(embedded, config, file);
result.put(locale, config);
});
@ -74,9 +74,9 @@ public class LocaleLoader {
if (!folder.exists()) {
folder.mkdirs();
}
String[] files = folder.list();
final String[] files = folder.list();
if (files == null || files.length == 0) {
Plugin plugin = LoParkour.getPlugin();
final Plugin plugin = LoParkour.getPlugin();
plugin.saveResource("locales/en.yml", false);
plugin.saveResource("locales/ru.yml", false);
}
@ -88,11 +88,11 @@ public class LocaleLoader {
private static void validateAndFix(@NotNull FileConfiguration reference,
@NotNull FileConfiguration locale,
@NotNull File file) {
List<String> refNodes = getChildren(reference);
List<String> locNodes = getChildren(locale);
final List<String> refNodes = getChildren(reference);
final List<String> locNodes = getChildren(locale);
boolean modified = false;
for (String node : refNodes) {
for (final String node : refNodes) {
if (!locNodes.contains(node)) {
LoParkour.log("Fixing missing config node %s in %s".formatted(node, file.getName()));
locale.set(node, reference.get(node));
@ -112,7 +112,7 @@ public class LocaleLoader {
@NotNull
private static List<String> getChildren(@NotNull FileConfiguration config) {
ConfigurationSection section = config.getConfigurationSection("");
final ConfigurationSection section = config.getConfigurationSection("");
return section != null ? new ArrayList<>(section.getKeys(true)) : Collections.emptyList();
}
}