Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ktlint to 0.47.1 #245

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[*.{kt,kts}]
indent_size=2
continuation_indent_size=2
continuation_indent_size=2
insert_final_newline=true
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true
ktlint_disabled_rules=annotation,argument-list-wrapping,spacing-between-declarations-with-annotations,filename
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ validatePlugins {

codeQualityTools {
ktlint {
toolVersion = '0.45.2'
toolVersion = '0.47.1'
}
detekt {
toolVersion = '1.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.gradle.api.model.ObjectFactory
import javax.inject.Inject

open class CodeQualityToolsPluginExtension @Inject constructor(
objectFactory: ObjectFactory
objectFactory: ObjectFactory,
) {
/**
* When set to true all enabled code quality tools will be configured in a way that even a single warning / error will fail the build process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import javax.inject.Inject
internal data class ReportingMetaInformation(
val reportId: String,
val fileEnding: String,
val fileNameSuffix: String
val fileNameSuffix: String,
)

internal interface DetektParameters : WorkParameters {
Expand Down Expand Up @@ -94,7 +94,7 @@ internal abstract class DetektWorker @Inject internal constructor(
val reportValue = listOf(
ReportingMetaInformation("plain", "txt", "plain"),
ReportingMetaInformation("xml", "xml", "checkstyle"),
ReportingMetaInformation("html", "html", "report")
ReportingMetaInformation("html", "html", "report"),
).joinToString(separator = ",") {
it.fileEnding + ":" + File(parameters.outputDirectory.asFile.get(), "detekt-${it.fileNameSuffix}.${it.fileEnding}").absolutePath
}
Expand All @@ -104,7 +104,7 @@ internal abstract class DetektWorker @Inject internal constructor(
task.classpath = parameters.classpath
task.args(
"--input", parameters.inputFile.get().asFile,
reportKey, reportValue
reportKey, reportValue,
)

val configFile = parameters.configFile.asFile.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal abstract class KtLintWorker @Inject internal constructor(
"**/*.kt",
"**/*.kts",
"!build/",
"!build/**"
"!build/**",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class CodeQualityToolsPluginDetektTest {
<ID>InvalidPackageDeclaration:Foo.kt$.Foo.kt</ID>
</Whitelist>
</SmellBaseline>
""".trimIndent()
""".trimIndent(),
)
.withKotlinFile(testPath, "fun foo(i: Int) = i * 3\n")
.succeeds()
Expand Down Expand Up @@ -131,7 +131,7 @@ class CodeQualityToolsPluginDetektTest {
private val baselineFileName: String? = null,
buildUponDefaultConfig: Boolean = false,
parallel: Boolean = false,
inputDirectoryName: String = "."
inputDirectoryName: String = ".",
) {
init {
directory.newFile("build.gradle").writeText(
Expand Down Expand Up @@ -161,7 +161,7 @@ class CodeQualityToolsPluginDetektTest {
| jcenter()
|}
|
""".trimMargin()
""".trimMargin(),
)
}

Expand All @@ -186,7 +186,7 @@ class CodeQualityToolsPluginDetektTest {
taskToRun: String = "detektCheck",
taskToCheck: String = taskToRun,
assertReportsExist: Boolean = true,
containsMessage: String
containsMessage: String,
) = apply {
val buildResult = run(taskToRun).buildAndFail()
assertEquals(TaskOutcome.FAILED, buildResult.task(":$taskToCheck")?.outcome)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class CodeQualityToolsPluginKotlinTest {
"""
@Deprecated("Don't use this") fun bar() = { }
fun foo() = bar()
""".trimIndent()
""".trimIndent(),
)
.fails(containsMessage = "bar(): () -> Unit' is deprecated. Don't use this")
}

class Roboter(
private val directory: TemporaryFolder
private val directory: TemporaryFolder,
) {
init {
directory.newFile("build.gradle").writeText(
Expand All @@ -55,7 +55,7 @@ class CodeQualityToolsPluginKotlinTest {
| implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.41'
|}
|
""".trimMargin()
""".trimMargin(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CodeQualityToolsPluginKtlintTest {
"""
|[*.{kt,kts}]
|insert_final_newline=true
""".trimMargin()
""".trimMargin(),
)
.withKotlinFile("src/main/kotlin/com/vanniktech/test/Foo.kt", "fun foo(param: Int) = param * param")
.fails(containsMessage = "/src/main/kotlin/com/vanniktech/test/Foo.kt:1:1: File must end with a newline (\\n)")
Expand All @@ -41,7 +41,7 @@ class CodeQualityToolsPluginKtlintTest {
"""
|[*.{kt,kts}]
|insert_final_newline=true
""".trimMargin()
""".trimMargin(),
)
.withKotlinFile("src/main/kotlin/com/vanniktech/test/Foo.kt", "fun foo(param: Int) = param * param")
.succeeds(taskToRun = "ktlintFormat")
Expand All @@ -54,7 +54,7 @@ class CodeQualityToolsPluginKtlintTest {
"""
|[*.{kt,kts}]
|insert_final_newline=true
""".trimMargin()
""".trimMargin(),
)
.withKotlinFile("src/main/kotlin/com/vanniktech/test/Foo.kt", "fun foo(param: Int) = param * param")
.succeeds(taskToRun = "ktlintFormat")
Expand Down Expand Up @@ -119,7 +119,7 @@ class CodeQualityToolsPluginKtlintTest {
private val directory: TemporaryFolder,
enabled: Boolean = true,
version: String = "0.44.0",
experimental: Boolean = false
experimental: Boolean = false,
) {
init {
directory.newFile("build.gradle").writeText(
Expand Down Expand Up @@ -149,7 +149,7 @@ class CodeQualityToolsPluginKtlintTest {
| implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.41'
|}
|
""".trimMargin()
""".trimMargin(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ abstract class CommonCodeQualityToolsTest {
// Project javaGradlePluginProject We can't use this one yet since testing takes forever then.

lateinit var kotlinProjects: Array<Project>

// Project kotlinProject groovy.lang.MissingPropertyException: No such property: KotlinPlugin for class
// Project kotlinAndroidProject groovy.lang.MissingPropertyException: No such property: KotlinPlugin for class
lateinit var kotlinPlatformCommonProject: Project
Expand Down Expand Up @@ -70,24 +71,24 @@ abstract class CommonCodeQualityToolsTest {
androidTestProject.plugins.apply(TestPlugin::class.java)

emptyProjects = arrayOf(
emptyProject
emptyProject,
)

javaProjects = arrayOf(
javaProject,
javaLibraryProject
javaLibraryProject,
)

kotlinProjects = arrayOf(
kotlinPlatformCommonProject,
kotlinPlatformJvmProject,
kotlinPlatformJsProject
kotlinPlatformJsProject,
)

androidProjects = arrayOf(
androidAppProject,
androidLibraryProject,
androidTestProject
androidTestProject,
)

projects = emptyProjects + javaProjects + kotlinProjects + androidProjects
Expand Down
3 changes: 2 additions & 1 deletion src/test/kotlin/com/vanniktech/code/quality/tools/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ fun defaultExtensions(): CodeQualityToolsPluginExtension {
override fun <T : Any?> newInstance(type: Class<out T>, vararg parameters: Any?): T {
return type.newInstance()
}
})
},
),
)
}

Expand Down