DEADSOFTWARE

Add ktlint plugin
authorfredboy <fredboy@protonmail.com>
Tue, 1 Jul 2025 13:14:39 +0000 (20:14 +0700)
committerfredboy <fredboy@protonmail.com>
Tue, 1 Jul 2025 13:14:39 +0000 (20:14 +0700)
39 files changed:
android/build.gradle.kts
buildSrc/src/main/kotlin/Dependencies.kt
buildSrc/src/main/kotlin/PluginDependencySpecScopeExtentions.kt
buildSrc/src/main/kotlin/Versions.kt
core/common/build.gradle.kts
core/data/assets/build.gradle.kts
core/data/configuration/build.gradle.kts
core/data/items/build.gradle.kts
core/data/menu/build.gradle.kts
core/data/save/build.gradle.kts
core/domain/assets/build.gradle.kts
core/domain/configuration/build.gradle.kts
core/domain/items/build.gradle.kts
core/domain/menu/build.gradle.kts
core/domain/save/build.gradle.kts
core/domain/world/build.gradle.kts
core/entity/container/build.gradle.kts
core/entity/drop/build.gradle.kts
core/entity/mob/build.gradle.kts
core/entity/mob/src/main/kotlin/ru/fredboy/cavedroid/entity/mob/model/Player.kt
core/game/controller/container/build.gradle.kts
core/game/controller/container/src/main/kotlin/ru/fredboy/cavedroid/game/controller/container/ContainerController.kt
core/game/controller/drop/build.gradle.kts
core/game/controller/drop/src/main/kotlin/ru/fredboy/cavedroid/game/controller/drop/DropController.kt
core/game/controller/mob/build.gradle.kts
core/game/controller/mob/src/main/kotlin/ru/fredboy/cavedroid/game/controller/mob/behavior/BaseMobBehavior.kt
core/game/window/build.gradle.kts
core/game/world/build.gradle.kts
core/ux/controls/build.gradle.kts
core/ux/controls/src/main/kotlin/ru/fredboy/cavedroid/ux/controls/GameInputProcessor.kt
core/ux/controls/src/main/kotlin/ru/fredboy/cavedroid/ux/controls/input/handler/mouse/UseItemMouseInputHandler.kt
core/ux/controls/src/main/kotlin/ru/fredboy/cavedroid/ux/controls/input/handler/touch/JoystickInputHandler.kt
core/ux/physics/build.gradle.kts
core/ux/rendering/build.gradle.kts
core/zygote/build.gradle.kts
core/zygote/src/main/kotlin/ru/fredboy/cavedroid/zygote/CaveDroidApplication.kt
core/zygote/src/main/kotlin/ru/fredboy/cavedroid/zygote/menu/input/MenuInputProcessor.kt
core/zygote/src/main/kotlin/ru/fredboy/cavedroid/zygote/menu/renderer/MenuRenderer.kt
desktop/build.gradle.kts

index ebf9914f125eefcbcc58ec31aad4739f32330eff..34932be0afe44b25468c2ac84541fca8d873d5e5 100644 (file)
@@ -6,6 +6,7 @@ private val natives by configurations.creating
 plugins {
     id("com.android.application")
     id("kotlin-android")
+    ktlintGradle
 }
 
 private val keystorePropertiesFile = rootProject.file("keystore.properties")
index 95d5439d4c50b9ec3489f869bbe8a65304497217..609f671658714b4d4beb35cde475642f717a404e 100644 (file)
@@ -44,9 +44,10 @@ object Dependencies {
         const val ksp = "ru.fredboy:automultibind-ksp:${Versions.automultibind}"
     }
 
-    const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.agp}"
+    object KtLint {
+        const val ktlintGradlePlugin = "org.jlleitschuh.gradle:ktlint:${Versions.ktlintGradle}"
+    }
 
-    // TODO: Remove after complete kotlin migration
-    const val jetbrainsAnnotations = "org.jetbrains:annotations:${Versions.jetbrainsAnnotations}"
+    const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.agp}"
 
 }
\ No newline at end of file
index 19972d7eca234da0da20fd601fa200c6b05243f8..b2de3210fa5d6979be05f16d4c7150e5532609c2 100644 (file)
@@ -7,3 +7,5 @@ val PluginDependenciesSpecScope.ksp
     get() = id("com.google.devtools.ksp") version Versions.ksp
 val PluginDependenciesSpecScope.kotlinxSerialization
     get() = id("org.jetbrains.kotlin.plugin.serialization") version Versions.kotlin
+val PluginDependenciesSpecScope.ktlintGradle
+    get() = id("org.jlleitschuh.gradle.ktlint") version Versions.ktlintGradle
index 69bfd298b92a1aec654c11cfba2856533098ca22..a5ae05bf0fdd9e285389184897af7bd7ad183553 100644 (file)
@@ -60,4 +60,11 @@ object Versions {
      * [Source](https://github.com/fredboy/automultibind)
      */
     const val automultibind = "1.0.0"
+
+    /**
+     * Ktlint gradle plugin
+     *
+     * [Source](https://github.com/JLLeitschuh/ktlint-gradle)
+     */
+    const val ktlintGradle = "12.3.0"
 }
\ No newline at end of file
index 114a57754088b460b52c162123f9c09a1aa5cec8..6b424c781304221a9f8ef2cef976d986cce41a08 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 8ab6f7c009b1ad6f71ecf9941d83d902b7b40912..892762bfcdc74287ba4edf3fe7ceb504bed74882 100644 (file)
@@ -2,6 +2,7 @@ plugins {
     kotlin
     ksp
     kotlinxSerialization
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 2092f364ec616113c9f35f030b3885ef2032a9cf..49f56ad1f94153512477984d919a0bc5a7e1270b 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index dfd5c0fb8f7d3672584b8039fa8d94d45540a52b..b1aeda56b3f386f30742ab783424acc4c77cc49d 100644 (file)
@@ -2,6 +2,7 @@ plugins {
     kotlin
     ksp
     kotlinxSerialization
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 73fdbcc3132c32f3546f2826032ea385783dc272..5925c90fb40ebb00713abdfd23faa5cb5302f069 100644 (file)
@@ -2,6 +2,7 @@ plugins {
     kotlin
     ksp
     kotlinxSerialization
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 1153b84e1ca9f5dc8dd5684e7ab7fb3c7b3ac91d..3fa936c74c85bae1e620e648ac34a27b5cf0db2b 100644 (file)
@@ -2,6 +2,7 @@ plugins {
     kotlin
     ksp
     kotlinxSerialization
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 9d3840d4d361c7b01f982d303e7ccb680d063672..df17486f7a00f3e2065350ccc8253ad217b53d9e 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 86474f1008d30aee5787f738cf500808fddcdbc6..8cdad92ec0bb1aecb73c627fdb035882bcfcb6d4 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 9d3840d4d361c7b01f982d303e7ccb680d063672..df17486f7a00f3e2065350ccc8253ad217b53d9e 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 9d3840d4d361c7b01f982d303e7ccb680d063672..df17486f7a00f3e2065350ccc8253ad217b53d9e 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 8ebc8cba8986c3d12fe97f2e3141abc7bd13246f..5860b880f26ffb0b357397b75d189f9c93523a78 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index ef847ce1114547aca7eed7d970e6069ecdb97e02..cba775caa7a7812a38a05169c6c9d44bab223309 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 1cc022fdca0585284558f4778703e7e63c6bca49..ac98934e315a800e08b753c411e241cf7e26707a 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 1cc022fdca0585284558f4778703e7e63c6bca49..ac98934e315a800e08b753c411e241cf7e26707a 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index fee0959eafef18de600b1bdf0134b285e46e4180..80f1a5908f748537ab0dc723f3b93fc134fef95f 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 8ac4643838ca0f667ba751b2c4cbae231b4bd46c..eb37e56ea33bfc2848f79f287ff05e393b387436 100644 (file)
@@ -97,8 +97,8 @@ class Player(
             leg.setOrigin(leg.width / 2f, 0f)
             head.setOrigin(head.width / 2, head.height)
 
-            var backHandAnim = 0f
-            var frontHandAnim = 0f
+            var backHandAnim: Float
+            var frontHandAnim: Float
 
             val rightHandAnim = getRightHandAnim(delta)
 
index 43efa9b35a3df13eeba6a75a5ab1a7c36685f16e..9694ac13e2d9b161180bea48d72538a8bcc57ad8 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index e05765d32264d8864619ced1743d881c24241917..17d6dd0632c560c24854301944d0d762043a5312 100644 (file)
@@ -63,6 +63,7 @@ class ContainerController @Inject constructor(
         }
     }
 
+    @Suppress("unused")
     fun update(delta: Float) {
         val iterator = containerMap.iterator()
         while (iterator.hasNext()) {
index d58c8e55dfbc40a51bb13a0d370055fa57a81007..62337d8c1e89333111b1146c1049ca799e3ad10b 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 2ca41cb61aaeca2cebe9db74ced06a4ce158dac2..8275613f5c9f58a7854f0fe6624607ccb9830129 100644 (file)
@@ -59,6 +59,7 @@ class DropController @Inject constructor(
         drops.forEach(action)
     }
 
+    @Suppress("unused")
     fun update(delta: Float) {
         val iterator = drops.iterator()
 
index ac2a09245737eab7cd740f409e70ccf57b242bfc..97a40f83957367e4ff422ade8eeb03715a684468 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index de75a4e19b6a5bf22d4a5dee05c3cd2f3d53b1bb..1f1f15b77c03213234be2a8da33d985c7a35a827 100644 (file)
@@ -9,6 +9,7 @@ abstract class BaseMobBehavior<MOB : Mob>(
     val mobType: KClass<MOB>,
 ) : MobBehavior {
 
+    @Suppress("UNCHECKED_CAST")
     final override fun update(mob: Mob, worldAdapter: MobWorldAdapter, delta: Float) {
         if (mob::class == mobType) {
             with(mob as MOB) {
index d84f920099b04bd22b2d5403e114779328554220..aa0c659f27ab0a7feb7cc31f4fcb9ef622f6eed7 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 317d76b82b3ed246a8fe05936c0ede976193d13c..74cb1f285b5a62983bc0cee1a11f4da1b7267202 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 68aca5e1e41804a5fe6980461719f37d9d4c05da..7433a2236e6e9f0dcb9b17236d536dc6854ba7ff 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index d9eff9004549712acece8ee6118a66cd406de8e1..028d63016260cb595b54a7bda300c5845bf672b6 100644 (file)
@@ -177,6 +177,7 @@ class GameInputProcessor @Inject constructor(
     }
 
 
+    @Suppress("unused")
     fun update(delta: Float) {
         handleMousePosition()
     }
@@ -264,7 +265,7 @@ class GameInputProcessor @Inject constructor(
         val action: MouseInputAction? = mouseInputActionMapper.map(
             mouseX = mouseX.toFloat(),
             mouseY = mouseY.toFloat(),
-            cameraViewport = requireNotNull(gameContextRepository.getCameraContext()?.viewport),
+            cameraViewport = requireNotNull(gameContextRepository.getCameraContext().viewport),
             button = button,
             touchUp = touchUp,
             pointer = pointer,
index 355cf5c44d2f62ea40a048f7ce19c956d51db885..35aef0bb32fb1bd44d646f6c08a9ef40b828df1b 100644 (file)
@@ -47,7 +47,7 @@ class UseItemMouseInputHandler @Inject constructor(
         buttonHoldTask = null
     }
 
-    private fun handleHold(action: MouseInputAction) {
+    private fun handleHold() {
         cancelHold()
 
         val player = mobController.player
@@ -64,11 +64,11 @@ class UseItemMouseInputHandler @Inject constructor(
         }
     }
 
-    private fun handleDown(action: MouseInputAction) {
+    private fun handleDown() {
         cancelHold()
         buttonHoldTask = object : Timer.Task() {
             override fun run() {
-                handleHold(action)
+                handleHold()
             }
 
         }
@@ -89,7 +89,7 @@ class UseItemMouseInputHandler @Inject constructor(
         )
     }
 
-    private fun handleUp(action: MouseInputAction) {
+    private fun handleUp() {
         val player = mobController.player
         val item = player.activeItem.item
         cancelHold()
@@ -123,9 +123,9 @@ class UseItemMouseInputHandler @Inject constructor(
         }
 
         if (action.actionKey.touchUp && buttonHoldTask?.isScheduled == true) {
-            handleUp(action)
+            handleUp()
         } else if (!action.actionKey.touchUp) {
-            handleDown(action)
+            handleDown()
         }
     }
 
index b39c725b92ca64db1ec2c5a1ca77f14ae385b43d..fe22fdc185962b1f7c58f5c69a5faac87b23318c 100644 (file)
@@ -55,14 +55,8 @@ class JoystickInputHandler @Inject constructor(
 
     override fun checkConditions(action: MouseInputAction): Boolean {
         return gameWindowsManager.currentWindowType == GameWindowType.NONE &&
-                applicationContextRepository.isTouch() &&
-//                mobsController.player.controlMode == Player.ControlMode.WALK &&
-                gameContextRepository.getJoystick() != null &&
-                (action.actionKey is MouseInputActionKey.Touch) &&
-                (action.actionKey.pointer == gameContextRepository.getJoystick().pointer || !active) &&
-                ((action.actionKey is MouseInputActionKey.Dragged) ||
-                        (action.screenX < action.cameraViewport.width / 2 && !action.actionKey.touchUp || active)) &&
-                !(action.actionKey is MouseInputActionKey.Screen && action.isInsideHotbar(textureRegions))
+                applicationContextRepository.isTouch() && action.actionKey is MouseInputActionKey.Touch && (action.actionKey.pointer == gameContextRepository.getJoystick().pointer || !active) && ((action.actionKey is MouseInputActionKey.Dragged) ||
+                (action.screenX < action.cameraViewport.width / 2 && !action.actionKey.touchUp || active)) && !(action.actionKey is MouseInputActionKey.Screen && action.isInsideHotbar(textureRegions))
 
     }
 
@@ -72,8 +66,8 @@ class JoystickInputHandler @Inject constructor(
         active = true
     }
 
-    private fun handleTouchUp(action: MouseInputAction) {
-        gameContextRepository.getJoystick()?.deactivate()
+    private fun handleTouchUp() {
+        gameContextRepository.getJoystick().deactivate()
         active = false
     }
 
@@ -139,7 +133,7 @@ class JoystickInputHandler @Inject constructor(
             is MouseInputActionKey.Dragged -> handleDragged()
             else -> {
                 if (action.actionKey.touchUp) {
-                    handleTouchUp(action)
+                    handleTouchUp()
                 } else {
                     handleTouchDown(action)
                 }
index a2da836e427fa3f231c892872cff374dcc6a0d63..b07c65930d5859a3d5a452beeebc3f0cbec10060 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 870744fd44f3a4008cb5f63e7515028775b439b8..d4c106e941ffde65cc7d1a4d4dbf554aa9aa3974 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index d315c7fa4b0333f2d509828ab060892943de9907..e478fe99aa0949586775c8d1284a48133bd79f47 100644 (file)
@@ -1,6 +1,7 @@
 plugins {
     kotlin
     ksp
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility
index 01f2b5bd8dce834ad6355ff7a0df67a439196054..0ba8bfbb84d1b2ed49bc08ba9c7aab90346cd07a 100644 (file)
@@ -75,7 +75,7 @@ class CaveDroidApplication(
 
     override fun quitGame() {
         (screen as? GameScreen)?.let { gameScreen ->
-            screen.dispose()
+            gameScreen.dispose()
             setScreen(applicationComponent.menuScreen)
         } ?: Gdx.app.error(TAG, "quitGame called when active screen is not Game")
     }
index 2c80a40daa082db6524552c8e36c68972b4f18c1..b6b56f0c37557ac1c5b597b94a238c9f06842d15 100644 (file)
@@ -28,8 +28,8 @@ class MenuInputProcessor @Inject constructor(
         val touchX = applicationContextRepository.getWidth() / Gdx.graphics.width * screenX.toFloat()
         val touchY = applicationContextRepository.getHeight() / Gdx.graphics.height * screenY.toFloat()
 
-        menuButtonRepository.getCurrentMenuButtons()?.values?.forEachIndexed { index, button ->
-            if (!button.isEnabled) {
+        menuButtonRepository.getCurrentMenuButtons()?.values?.forEachIndexed { index, menuButton ->
+            if (!menuButton.isEnabled) {
                 return@forEachIndexed
             }
 
@@ -42,22 +42,22 @@ class MenuInputProcessor @Inject constructor(
             )
 
             if (rect.contains(touchX, touchY)) {
-                when (button) {
+                when (menuButton) {
                     is MenuButton.Simple -> {
-                        val action = menuButtonActions[button.actionKey] ?: run {
-                            Gdx.app.error(TAG, "Menu handler for action '${button.actionKey}' not found")
+                        val action = menuButtonActions[menuButton.actionKey] ?: run {
+                            Gdx.app.error(TAG, "Menu handler for action '${menuButton.actionKey}' not found")
                             return@forEachIndexed
                         }
 
                         if (action.canPerform()) {
                             action.perform()
                         } else {
-                            Gdx.app.debug(TAG, "Can't perform action ${button.actionKey}")
+                            Gdx.app.debug(TAG, "Can't perform action ${menuButton.actionKey}")
                         }
                     }
 
                     is MenuButton.BooleanOption -> {
-                        button.optionKeys.forEach { optionKey ->
+                        menuButton.optionKeys.forEach { optionKey ->
                             menuButtonBooleanOption[optionKey]?.toggleOption() ?: run {
                                 Gdx.app.error(TAG, "Menu option handler for option '$optionKey' not found")
                             }
index 8401e30da0ab013626a949203959c9f67f141ec3..5921de7828125b92b1d58129fa5bf504ca7730a0 100644 (file)
@@ -130,6 +130,7 @@ class MenuRenderer @Inject constructor(
         spriter.projectionMatrix = camera.combined
     }
 
+    @Suppress("unused")
     fun render(delta: Float) {
         spriter.begin()
         drawBackground()
index 910d67e6b7533458d1ffc30e9e8030219bd9675b..6412b14423cc43e3be6ba2ca5c6b23f5187869c7 100644 (file)
@@ -1,5 +1,6 @@
 plugins {
-    id("kotlin")
+    kotlin
+    ktlintGradle
 }
 
 java.sourceCompatibility = ApplicationInfo.sourceCompatibility