From b34cb151ab8e29211d52f0b1f7e16f4f8cf50788 Mon Sep 17 00:00:00 2001 From: Username404 Date: Sat, 19 Jun 2021 12:24:22 +0200 Subject: [PATCH] Use diktat directly instead of the spotless gradle plugin and improve a few files --- Formatting.yml | 11 +++++++++++ build.gradle.kts | 19 ++++++++----------- .../snowygui/config/Configuration.kt | 5 ++++- .../snowygui/gui/feature/GammaBoost.kt | 5 +++-- .../username404/snowygui/misc/AddKeyMaps.kt | 14 ++++++++------ 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/Formatting.yml b/Formatting.yml index 9a59d82..3ccd535 100644 --- a/Formatting.yml +++ b/Formatting.yml @@ -7,6 +7,13 @@ - name: SAY_NO_TO_VAR enabled: true +- name: TRAILING_COMMA + enabled: true + configuration: + valueArgument: true + valueParameter: true + collectionLiteral: true + - name: UNUSED_IMPORT enabled: true @@ -15,6 +22,10 @@ - name: WRONG_INDENTATION enabled: true + configuration: + extendedIndentOfParameters: false + alignedParameters: true + indentationSize: 4 - name: TYPEALIAS_NAME_INCORRECT_CASE enabled: false diff --git a/build.gradle.kts b/build.gradle.kts index bcd46f1..5aabb1f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ plugins { id("dev.architectury.loom") version "[0.7.2.110, 0.9.0[" apply false id("com.github.ben-manes.versions") version "0.39.0" id("net.kyori.indra.git") version "2.0.5" - id("com.diffplug.spotless") version "5.12.5" + id("org.cqfn.diktat.diktat-gradle-plugin") version "0.6.2" id("com.modrinth.minotaur") version "1.2.1" } @@ -39,6 +39,12 @@ val kotlinX: String = "org.jetbrains.kotlinx" subprojects { group = rootProject.group.toString() + apply(plugin = "org.cqfn.diktat.diktat-gradle-plugin") + diktat { + inputs = files("src/**/*.kt") + diktatConfigFile = file("$rootDir/Formatting.yml") + ignoreFailures = true + } lateinit var mappingsDep: Dependency apply(plugin = "dev.architectury.loom") apply(plugin = "org.jetbrains.kotlin.plugin.serialization") @@ -146,6 +152,7 @@ subprojects { input.set(shrinkedJar) if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars")) } + build.get().dependsOn(diktatCheck) } } @@ -162,16 +169,6 @@ allprojects { **/ apply(plugin = "java") apply(plugin = "org.jetbrains.kotlin.jvm") - apply(plugin = "com.diffplug.spotless") - spotless { - encoding = Charsets.UTF_8 - kotlin { - ignoreErrorForStep("diktat") - diktat("0.6.1").configFile("$rootDir/Formatting.yml") - trimTrailingWhitespace(); endWithNewline() - } - } - tasks.spotlessCheck.get().finalizedBy(tasks.spotlessApply) apply(plugin = "architectury-plugin") val compiler = javaToolchains.compilerFor { languageVersion.set(JavaLanguageVersion.of(sourceJavaVer.toInt())) } dependencies { diff --git a/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt b/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt index 9ac445d..60345e9 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/config/Configuration.kt @@ -2,7 +2,10 @@ package fr.username404.snowygui.config import com.typesafe.config.Config import com.typesafe.config.ConfigException -import com.typesafe.config.ConfigFactory.* +import com.typesafe.config.ConfigFactory.empty +import com.typesafe.config.ConfigFactory.parseFile +import com.typesafe.config.ConfigFactory.load +import com.typesafe.config.ConfigFactory.parseString import com.typesafe.config.ConfigRenderOptions import com.typesafe.config.ConfigValueFactory import fr.username404.snowygui.ClickGui diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt index 326ff18..03a34d3 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/GammaBoost.kt @@ -4,12 +4,13 @@ import net.minecraft.client.Minecraft @ButtonInfo(Category.MISC) object GammaBoost: ButtonImpl() { + private const val boost = 1400.0 private var oldGamma = 0.0 override fun execAction() { with(Minecraft.getInstance().options) { gamma = if (toggled) { - if (gamma < 1400.0) oldGamma = gamma - 1400.0 + if (gamma < boost) oldGamma = gamma + boost } else oldGamma } } diff --git a/common/src/main/kotlin/fr/username404/snowygui/misc/AddKeyMaps.kt b/common/src/main/kotlin/fr/username404/snowygui/misc/AddKeyMaps.kt index 596eac9..850de13 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/misc/AddKeyMaps.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/misc/AddKeyMaps.kt @@ -13,12 +13,14 @@ private typealias privateLambda = (() -> Unit)? object AddKeyMaps { private const val prefix = "snowy" @JvmOverloads - internal fun mkMap(translationSuffix: String, key: Int, category: String = "keycategory", lambda: privateLambda = null): Pair { - return KeyMapping( - "key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM, - key, "category.$prefix.$category" - ) to lambda - } + internal fun mkMap( + translationSuffix: String, + key: Int, category: String = "keycategory", + lambda: privateLambda = null + ): Pair = KeyMapping( + "key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM, + key, "category.$prefix.$category" + ) to lambda val list: MutableMap = with(Minecraft.getInstance()) { mutableMapOf( mkMap("opengui", GLFW_KEY_Y) { setScreen(ClickGui) },