diff --git a/.editorconfig b/.editorconfig index 2d6d258f47..b0d7bd3f97 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,14 @@ +[*] +max_line_length = off + [*.{kt,kts}] -ktlint_code_style = intellij_idea -ktlint_standard_no-wildcard-imports = disabled \ No newline at end of file +# ktlint entries are for ktlint gradle task and ktlint Intellij / Android Studio plugin. +# Ignore all 'property not supported' warnings, these are correct. +ktlint_code_style = android_studio +ktlint_standard_discouraged-comment-location = disabled +ktlint_standard_no-wildcard-imports = disabled +ij_kotlin_imports_layout=* +ij_kotlin_name_count_to_use_star_import = 5 +ij_kotlin_name_count_to_use_star_import_for_members = 5 +ij_kotlin_allow_trailing_comma_on_call_site = false +ij_kotlin_allow_trailing_comma = false diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000000..7a0ae16800 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000000..79ee123c2b --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index e086a70c4e..f1854e4b53 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,5 +4,5 @@ - + \ No newline at end of file diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 4bba02a523..4bebe5e6eb 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -950,8 +950,8 @@ public final class app/revanced/patches/strava/upselling/DisableSubscriptionSugg public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/ticktick/misc/themeunlock/UnlockProPatch : app/revanced/patcher/patch/BytecodePatch { - public static final field INSTANCE Lapp/revanced/patches/ticktick/misc/themeunlock/UnlockProPatch; +public final class app/revanced/patches/ticktick/misc/themeunlock/UnlockThemesPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/ticktick/misc/themeunlock/UnlockThemesPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } diff --git a/build.gradle.kts b/build.gradle.kts index 58308fbf48..3da402dadc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { alias(libs.plugins.kotlin) + alias(libs.plugins.ktlint) alias(libs.plugins.binary.compatibility.validator) `maven-publish` signing @@ -67,8 +68,9 @@ tasks { dependsOn(build) doLast { - val d8 = File(System.getenv("ANDROID_HOME")).resolve("build-tools") - .listFilesOrdered().last().resolve("d8").absolutePath + val d8 = + File(System.getenv("ANDROID_HOME")).resolve("build-tools") + .listFilesOrdered().last().resolve("d8").absolutePath val patchesJar = configurations.archives.get().allArtifacts.files.files.first().absolutePath val workingDirectory = layout.buildDirectory.dir("libs").get().asFile diff --git a/gradle.properties b/gradle.properties index 4c62d5701b..75732fcb82 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.parallel = true org.gradle.caching = true -kotlin.code.style = official +kotlin.code.style = auto # Use Project style setting. version = 4.6.0-dev.1 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a4c08e8987..279c277a1c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,6 +5,7 @@ guava = "33.0.0-jre" gson = "2.10.1" binary-compatibility-validator = "0.14.0" kotlin = "1.9.22" +ktlint = "12.1.0" [libraries] revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" } @@ -15,3 +16,4 @@ gson = { module = "com.google.code.gson:gson", version.ref = "gson" } [plugins] binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" } kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } diff --git a/src/main/kotlin/app/revanced/generator/JsonPatchesFileGenerator.kt b/src/main/kotlin/app/revanced/generator/JsonPatchesFileGenerator.kt index 28871d6d10..e2f810f6db 100644 --- a/src/main/kotlin/app/revanced/generator/JsonPatchesFileGenerator.kt +++ b/src/main/kotlin/app/revanced/generator/JsonPatchesFileGenerator.kt @@ -6,27 +6,28 @@ import com.google.gson.GsonBuilder import java.io.File internal class JsonPatchesFileGenerator : PatchesFileGenerator { - override fun generate(patches: PatchSet) = patches.map { - JsonPatch( - it.name!!, - it.description, - it.compatiblePackages, - it.use, - it.requiresIntegrations, - it.options.values.map { option -> - JsonPatch.Option( - option.key, - option.default, - option.values, - option.title, - option.description, - option.required, - ) - }, - ) - }.let { - File("patches.json").writeText(GsonBuilder().serializeNulls().create().toJson(it)) - } + override fun generate(patches: PatchSet) = + patches.map { + JsonPatch( + it.name!!, + it.description, + it.compatiblePackages, + it.use, + it.requiresIntegrations, + it.options.values.map { option -> + JsonPatch.Option( + option.key, + option.default, + option.values, + option.title, + option.description, + option.required + ) + } + ) + }.let { + File("patches.json").writeText(GsonBuilder().serializeNulls().create().toJson(it)) + } @Suppress("unused") private class JsonPatch( @@ -35,7 +36,7 @@ internal class JsonPatchesFileGenerator : PatchesFileGenerator { val compatiblePackages: Set? = null, val use: Boolean = true, val requiresIntegrations: Boolean = false, - val options: List