From 297a1071f08f0bfd17d6d9924f4718da9044823b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 17 Mar 2024 11:03:35 +0000 Subject: [PATCH 1/2] Update dependency org.jlleitschuh.gradle.ktlint to v12 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 706bea3..a6031da 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] detekt = "1.23.5" kotlin = "1.9.23" -ktlintGradle = "11.6.1" +ktlintGradle = "12.1.0" pluginPublish = "1.2.1" versionCheck = "0.51.0" android-lint = "8.3.0" From bb796156f92242e245cdb2f58d2f7f6114eea0d7 Mon Sep 17 00:00:00 2001 From: Aditya Bhaskar Date: Sun, 17 Mar 2024 12:20:31 +0000 Subject: [PATCH 2/2] Change code style to intelliJ (default had changed to an opinionated 'ktlint official' style + Fix some lint errors --- .editorconfig | 7 +++---- .../plugin/DependencyGraphExtension.kt | 1 - .../dependencygraph/plugin/DependencyGraphPlugin.kt | 9 ++++++--- .../dependencygraph/plugin/DependencyGraphTask.kt | 13 ++++++++----- .../dependencygraph/plugin/core/DrawGraph.kt | 7 ++++++- .../dependencygraph/plugin/DependencyGraphTest.kt | 1 - 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.editorconfig b/.editorconfig index b5104f1..d86fac7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -778,13 +778,12 @@ ij_groovy_wrap_chain_calls_after_dot = false ij_groovy_wrap_long_lines = false [{*.kt,*.kts}] -# Ktlint specific rules and other overrides from standard rules -ktlint_disabled_rules = no-wildcard-imports -continuation_indent_size = 4 ij_kotlin_indent_size = 4 ij_kotlin_continuation_indent_size = 4 -twitter_compose_allowed_composition_locals = LocalIsDarkModeActive +ktlint_code_style = intellij_idea # or android_studio or ktlint_official (default) +ktlint_standard_property-naming = disabled +ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 2 # Kotlin/IJ rules ij_smart_tabs = false diff --git a/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphExtension.kt b/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphExtension.kt index 849f78c..ce1392f 100644 --- a/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphExtension.kt +++ b/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphExtension.kt @@ -7,7 +7,6 @@ import javax.inject.Inject @Suppress("UnnecessaryAbstractClass", "UndocumentedPublicClass") abstract class DependencyGraphExtension @Inject constructor(project: Project) { - private val objects = project.objects /** diff --git a/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphPlugin.kt b/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphPlugin.kt index 43e56cc..37231b0 100644 --- a/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphPlugin.kt +++ b/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphPlugin.kt @@ -9,9 +9,12 @@ abstract class DependencyGraphPlugin : Plugin { override fun apply(project: Project) { // Add the extension object val extension = project.extensions.create( - /* name = */ EXTENSION_NAME, - /* type = */ DependencyGraphExtension::class.java, - /* ...constructionArguments = */ project, + // name = + EXTENSION_NAME, + // type = + DependencyGraphExtension::class.java, + // ...constructionArguments = + project, ) // Add a task that uses configuration from the extension object diff --git a/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphTask.kt b/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphTask.kt index ec2bb14..df84f38 100644 --- a/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphTask.kt +++ b/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphTask.kt @@ -1,6 +1,5 @@ package io.github.adityabhaskar.dependencygraph.plugin -import io.github.adityabhaskar.dependencygraph.plugin.ShowLegend.* import io.github.adityabhaskar.dependencygraph.plugin.core.DrawConfig import io.github.adityabhaskar.dependencygraph.plugin.core.drawDependencyGraph import org.gradle.api.DefaultTask @@ -30,7 +29,9 @@ enum class Direction(internal val directionString: String) { * * [Never] will not add a legend to any graph */ enum class ShowLegend { - Always, OnlyInRootGraph, Never + Always, + OnlyInRootGraph, + Never, } /** @@ -57,7 +58,6 @@ enum class ShowLegend { * * Module nodes are clickable, clicking through to the graph of the respective module */ abstract class DependencyGraphTask : DefaultTask() { - init { group = BasePlugin.BUILD_GROUP description = "Generates dependency graph files for all local modules in the project." @@ -167,7 +167,7 @@ abstract class DependencyGraphTask : DefaultTask() { // Create graph of all dependencies val graph = parsedGraph.get() - val showLegend = showLegend.getOrElse(OnlyInRootGraph) + val showLegend = showLegend.getOrElse(ShowLegend.OnlyInRootGraph) val directionString = graphDirection.getOrElse(Direction.LeftToRight).directionString val fileName = appendMarkDownIfNeeded( providedFileName = graphFileName.getOrElse(DEFAULT_GRAPH_FILE_NAME), @@ -214,7 +214,10 @@ abstract class DependencyGraphTask : DefaultTask() { ) } - private fun createGraphUrl(repoUrl: String?, mainBranchName: String?): String? { + private fun createGraphUrl( + repoUrl: String?, + mainBranchName: String?, + ): String? { if (repoUrl == null) { return null } diff --git a/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/core/DrawGraph.kt b/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/core/DrawGraph.kt index ffad810..cc094c9 100644 --- a/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/core/DrawGraph.kt +++ b/plugin-build/plugin/src/main/kotlin/io/github/adityabhaskar/dependencygraph/plugin/core/DrawGraph.kt @@ -16,7 +16,12 @@ internal data class DrawConfig( val shouldGroupModules: Boolean, ) -@Suppress("LongMethod", "CyclomaticComplexMethod", "CognitiveComplexMethod", "ktlint:indent") +@Suppress( + "LongMethod", + "CyclomaticComplexMethod", + "CognitiveComplexMethod", + "ktlint:standard:indent", +) /** * Creates a graph of dependencies for the given project and writes it to a file in the project's * directory. diff --git a/plugin-build/plugin/src/test/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphTest.kt b/plugin-build/plugin/src/test/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphTest.kt index ee899b1..d571737 100644 --- a/plugin-build/plugin/src/test/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphTest.kt +++ b/plugin-build/plugin/src/test/kotlin/io/github/adityabhaskar/dependencygraph/plugin/DependencyGraphTest.kt @@ -6,7 +6,6 @@ import org.junit.Assert.assertNotNull import org.junit.Test class DependencyGraphTest { - @Test fun `plugin is applied correctly to the project`() { val project = ProjectBuilder.builder().build()