Add builder GUI, stricter checks, GPL-3 license and English comments
- GUI (phases 7-8): BuilderScreen, Panel, NumberSlider, CycleButton, BuilderUi keybinds (Right Shift menu, P pause macro), lang entries, README - ConfigStore.loadOrEmpty/saveQuietly; BuildSettings.Range; BuilderFeature settings()/stage()/togglePause() - Checks: ~60 Checkstyle rules (errors), PMD with 7 categories, checkArchitecture (layer rules + max 4 files per package, with baseline), javac -Xlint:all -Werror, rule rejecting non-English comments - File length limit raised to 250 lines - License: GPL-3.0-only (LICENSE, fabric.mod.json) - All code comments and log messages translated to English
This commit is contained in:
parent
b26dfbbade
commit
d9df098064
130 changed files with 1779 additions and 267 deletions
|
|
@ -44,6 +44,7 @@ java {
|
|||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
options.release.set(21)
|
||||
options.compilerArgs.addAll(listOf("-Xlint:all,-processing,-serial,-classfile", "-Werror"))
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
|
|
@ -53,7 +54,7 @@ tasks.processResources {
|
|||
}
|
||||
}
|
||||
|
||||
// Правило проекта: файл максимум 200 строк — FileLength (severity=error валит check)
|
||||
// Правило проекта: файл максимум 250 строк — FileLength (severity=error валит check)
|
||||
checkstyle {
|
||||
toolVersion = "10.21.2"
|
||||
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
|
||||
|
|
@ -74,3 +75,48 @@ tasks.test {
|
|||
tasks.named("pmdTest") {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
// Архитектура (правила 6 и 11): максимум 4 файла в папке, слои зависят только вниз
|
||||
val maxFilesPerDir = 4
|
||||
val layerRules = mapOf(
|
||||
"util" to setOf<String>(),
|
||||
"core" to setOf("util"),
|
||||
"interaction" to setOf("core", "util"),
|
||||
"render" to setOf("util"),
|
||||
"feature" to setOf("core", "interaction", "render", "util"),
|
||||
"gui" to setOf("core", "feature", "render", "util"),
|
||||
)
|
||||
|
||||
tasks.register("checkArchitecture") {
|
||||
group = "verification"
|
||||
description = "Лимит файлов в папке и направление зависимостей между слоями"
|
||||
val srcRoot = layout.projectDirectory.dir("src/main/java/dev/loki/satura").asFile
|
||||
val baselineFile = layout.projectDirectory.file("config/architecture/baseline.txt").asFile
|
||||
doLast {
|
||||
val errors = mutableListOf<String>()
|
||||
srcRoot.walkTopDown().filter { it.isDirectory }.forEach { dir ->
|
||||
val count = dir.listFiles { f -> f.extension == "java" }?.size ?: 0
|
||||
if (count > maxFilesPerDir) {
|
||||
errors += "${dir.relativeTo(srcRoot)}: $count файлов (максимум $maxFilesPerDir)"
|
||||
}
|
||||
}
|
||||
val baseline = baselineFile.readLines().filter { it.isNotBlank() && !it.startsWith("#") }.toSet()
|
||||
val importRe = Regex("^import (?:static )?dev\\.loki\\.satura\\.([a-z]+)")
|
||||
srcRoot.walkTopDown().filter { it.extension == "java" }.forEach { file ->
|
||||
val rel = file.relativeTo(srcRoot).invariantSeparatorsPath
|
||||
val layer = rel.substringBefore('/')
|
||||
val allowed = layerRules[layer] ?: return@forEach
|
||||
file.readLines().mapNotNull { importRe.find(it)?.groupValues?.get(1) }.distinct()
|
||||
.filter { it != layer && it !in allowed }
|
||||
.filter { "$rel -> $it" !in baseline }
|
||||
.forEach { errors += "$rel: слой '$layer' не может импортировать '$it'" }
|
||||
}
|
||||
if (errors.isNotEmpty()) {
|
||||
throw GradleException("Нарушения архитектуры:\n" + errors.joinToString("\n") { " $it" })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("check") {
|
||||
dependsOn("checkArchitecture")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue