From 83382192c0c3d3dede7b7ab323c1e74f5f51a99b Mon Sep 17 00:00:00 2001 From: wakingrufus Date: Fri, 3 Mar 2023 12:29:03 -0600 Subject: [PATCH] fix new ktlint errors that come from our new default version of ktlint (#651) fix syntax bug in release logic for VERSION_LATEST_RELEASE.txt --- .github/workflows/new-release.yml | 2 +- CHANGELOG.md | 5 +++++ plugin/VERSION_LATEST_RELEASE.txt | 2 +- .../org/jlleitschuh/gradle/ktlint/KtlintExtension.kt | 6 ++++++ .../gradle/ktlint/reporter/CustomReporter.kt | 2 +- .../gradle/ktlint/reporter/ReporterType.kt | 2 +- .../gradle/ktlint/tasks/BaseKtLintCheckTask.kt | 3 ++- .../gradle/ktlint/tasks/LoadReportersTask.kt | 2 +- .../gradle/ktlint/worker/KtLintInvocation.kt | 5 +++-- .../org/jlleitschuh/gradle/ktlint/BuildCacheTest.kt | 11 ++++------- .../gradle/ktlint/ConfigurationCacheTest.kt | 3 ++- .../{testAnnotations.kt => TestAnnotations.kt} | 0 .../gradle/ktlint/testdsl/{testDsl.kt => TestDsl.kt} | 2 +- .../gradle/ktlint/worker/SerializableLintErrorTest.kt | 4 +--- 14 files changed, 29 insertions(+), 20 deletions(-) rename plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/{testAnnotations.kt => TestAnnotations.kt} (100%) rename plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/{testDsl.kt => TestDsl.kt} (99%) diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml index 5330360a..b65db229 100644 --- a/.github/workflows/new-release.yml +++ b/.github/workflows/new-release.yml @@ -42,7 +42,7 @@ jobs: GITHUB_KEY: ${{ secrets.GITHUB_TOKEN }} run: ./plugin/gradlew -p ./plugin githubRelease --no-daemon - name: Update VERSION_LATEST_RELEASE to new published version - run: cp plugin/VERSION_CURRENT.txt > plugin/VERSION_LATEST_RELEASE.txt + run: cp plugin/VERSION_CURRENT.txt plugin/VERSION_LATEST_RELEASE.txt - name: Update VERSION_LATEST_RELEASE uses: stefanzweifel/git-auto-commit-action@v4 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 668a6e43..92ae5c0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] +### Fixed + +- fix new ktlint errors that come from our new default version of ktlint [#651](https://github.com/JLLeitschuh/ktlint-gradle/pull/651) +- fix syntax bug in release logic for VERSION_LATEST_RELEASE.txt [#651](https://github.com/JLLeitschuh/ktlint-gradle/pull/651) + ## [11.3.1] - 2023-03-03 ### Fixed diff --git a/plugin/VERSION_LATEST_RELEASE.txt b/plugin/VERSION_LATEST_RELEASE.txt index 68d8f15e..0a47c95b 100644 --- a/plugin/VERSION_LATEST_RELEASE.txt +++ b/plugin/VERSION_LATEST_RELEASE.txt @@ -1 +1 @@ -11.1.0 +11.3.1 diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/KtlintExtension.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/KtlintExtension.kt index c4db8c89..36fe4d3e 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/KtlintExtension.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/KtlintExtension.kt @@ -46,26 +46,32 @@ internal constructor( * Enable verbose mode. */ val verbose: Property = objectFactory.property { set(false) } + /** * Enable debug mode. */ val debug: Property = objectFactory.property { set(false) } + /** * Enable android mode. */ val android: Property = objectFactory.property { set(false) } + /** * Enable console output mode. */ val outputToConsole: Property = objectFactory.property { set(true) } + /** * Enabled colored output to console. */ val coloredOutput: Property = objectFactory.property { set(true) } + /** * Specify the color of the terminal output. */ val outputColorName: Property = objectFactory.property { set("") } + /** * Whether or not to allow the build to continue if there are warnings; * defaults to {@code false}, as for any other static code analysis tool. diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/reporter/CustomReporter.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/reporter/CustomReporter.kt index 3b1495bb..b04fa3c4 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/reporter/CustomReporter.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/reporter/CustomReporter.kt @@ -18,7 +18,7 @@ data class CustomReporter( val name: String, val reporterId: String = name, var fileExtension: String = reporterId, - @Transient var dependency: Any? = null, + @Transient var dependency: Any? = null ) : Serializable { companion object { private const val serialVersionUID: Long = 2012775L diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/reporter/ReporterType.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/reporter/ReporterType.kt index 9fc753a5..d9cf15b9 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/reporter/ReporterType.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/reporter/ReporterType.kt @@ -7,7 +7,7 @@ enum class ReporterType( val reporterName: String, val availableSinceVersion: SemVer, val fileExtension: String, - val options: List, + val options: List ) : Serializable { PLAIN("plain", SemVer(0, 9, 0), "txt", emptyList()), PLAIN_GROUP_BY_FILE("plain", SemVer(0, 9, 0), "txt", listOf("group_by_file")), diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/BaseKtLintCheckTask.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/BaseKtLintCheckTask.kt index 8e3e9143..c1c96e1b 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/BaseKtLintCheckTask.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/BaseKtLintCheckTask.kt @@ -146,6 +146,7 @@ abstract class BaseKtLintCheckTask @Inject constructor( @Internal override fun getIncludes(): MutableSet = patternFilterable.includes + @Internal override fun getExcludes(): MutableSet = patternFilterable.excludes @@ -225,7 +226,7 @@ abstract class BaseKtLintCheckTask @Inject constructor( private fun logTaskExecutionState( inputChanges: InputChanges, - editorConfigUpdated: Boolean, + editorConfigUpdated: Boolean ) { logger.info("Executing ${if (inputChanges.isIncremental) "incrementally" else "non-incrementally"}") logger.info("Editorconfig files were changed: $editorConfigUpdated") diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/LoadReportersTask.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/LoadReportersTask.kt index 2cf7c9d0..30314fb6 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/LoadReportersTask.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/LoadReportersTask.kt @@ -26,7 +26,7 @@ import javax.inject.Inject internal abstract class LoadReportersTask @Inject constructor( private val workerExecutor: WorkerExecutor, objectFactory: ObjectFactory, - projectLayout: ProjectLayout, + projectLayout: ProjectLayout ) : DefaultTask() { @get:Classpath diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/worker/KtLintInvocation.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/worker/KtLintInvocation.kt index d5f08830..b427507b 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/worker/KtLintInvocation.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/worker/KtLintInvocation.kt @@ -170,7 +170,8 @@ private fun userDataToEditorConfigOverride(userData: Map): Any { defaultEditorConfigPropertiesClass.kotlin.memberProperties.firstOrNull { it.name == "ktlintDisabledRulesProperty" } ?: defaultEditorConfigPropertiesClass.kotlin.memberProperties.first { it.name == "disabledRulesProperty" } addMethod.invoke( - editorConfigOverride, disabledRulesProperty.getter.call(defaultEditorConfigProperties), + editorConfigOverride, + disabledRulesProperty.getter.call(defaultEditorConfigProperties), userData["disabled_rules"] ) } @@ -186,7 +187,7 @@ internal class ExperimentalParamsProviderInvocation( private val editorConfigPath: String?, private val ruleProviders: Set, private val userData: Map, - private val debug: Boolean, + private val debug: Boolean ) : KtLintInvocation { companion object Factory : KtLintInvocationFactory { fun initialize( diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/BuildCacheTest.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/BuildCacheTest.kt index 5236af38..e0818df4 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/BuildCacheTest.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/BuildCacheTest.kt @@ -25,13 +25,10 @@ class BuildCacheTest : AbstractPluginTest() { "test", GenerateReportsTask.LintType.CHECK ) - project(gradleVersion, projectPath = originalRoot) { configureDefaultProject() - build( - CHECK_PARENT_TASK_NAME, "--build-cache" - ) { + build(CHECK_PARENT_TASK_NAME, "--build-cache") { assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS) assertThat(task(":$testSourceCheckTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS) } @@ -73,7 +70,7 @@ class BuildCacheTest : AbstractPluginTest() { .appendText( //language=Groovy """ - + repositories { jcenter() } @@ -94,7 +91,7 @@ class BuildCacheTest : AbstractPluginTest() { private fun File.addBuildCacheSettings() = appendText( //language=Groovy """ - + buildCache { local { directory = '${localBuildCache.toURI()}' @@ -111,7 +108,7 @@ class BuildCacheTest : AbstractPluginTest() { "src/test/kotlin/Test.kt", """ class Test - + """.trimIndent() ) } diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/ConfigurationCacheTest.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/ConfigurationCacheTest.kt index d259b5c0..5b882d91 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/ConfigurationCacheTest.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/ConfigurationCacheTest.kt @@ -67,7 +67,8 @@ class ConfigurationCacheTest : AbstractPluginTest() { build( configurationCacheFlag, configurationCacheWarnFlag, - FORMAT_PARENT_TASK_NAME, "--debug" + FORMAT_PARENT_TASK_NAME, + "--debug" ) { assertThat(task(":$formatTaskName")?.outcome).isEqualTo(TaskOutcome.UP_TO_DATE) assertThat(task(":$mainSourceSetFormatTaskName")?.outcome).isEqualTo(TaskOutcome.UP_TO_DATE) diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testAnnotations.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/TestAnnotations.kt similarity index 100% rename from plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testAnnotations.kt rename to plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/TestAnnotations.kt diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testDsl.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/TestDsl.kt similarity index 99% rename from plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testDsl.kt rename to plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/TestDsl.kt index 55fa4aed..97c2ae80 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/testDsl.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/testdsl/TestDsl.kt @@ -147,7 +147,7 @@ private val GradleVersion.supportedKotlinVersion fun projectSetup( kotlinPluginType: String, - gradleVersion: GradleVersion, + gradleVersion: GradleVersion ): (File) -> Unit = { val kotlinPluginVersion = gradleVersion.supportedKotlinVersion //language=Groovy diff --git a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/worker/SerializableLintErrorTest.kt b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/worker/SerializableLintErrorTest.kt index 2a8dfe9c..11ef98e4 100644 --- a/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/worker/SerializableLintErrorTest.kt +++ b/plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/worker/SerializableLintErrorTest.kt @@ -14,9 +14,7 @@ internal class SerializableLintErrorTest { @Test internal fun `Should correctly serialize and deserialize LintError`() { - val lintError = LintError( - 14, 154, "test-rule", "details about error", false - ) + val lintError = LintError(14, 154, "test-rule", "details about error", false) val wrappedLintError = SerializableLintError(lintError) val serializeIntoFile = temporaryFolder.resolve("lintError.test")