-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add spotless code formatter #6630
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull_request_template.md
needs to be updated. Otherwise LGTM 👍
spotless { | ||
kotlin { | ||
ktlint(libs.versions.ktlint.get()) | ||
.setEditorConfigPath("$projectDir/.editorconfig") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary override, it's the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I'll create a follow up change
.setEditorConfigPath("$projectDir/.editorconfig") | ||
target("**/*.kt") | ||
targetExclude("**/build/", "**/resources/", "plugins/openpgp-api-lib/") | ||
endWithNewline() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rule had been covered by insert_final_newline
in .editorconfig
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I'll create a follow up change
@@ -38,7 +39,7 @@ ksp = "com.google.devtools.ksp:1.8.0-1.0.8" | |||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } | |||
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } | |||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } | |||
ktlint = "org.jlleitschuh.gradle.ktlint:11.0.0" | |||
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just inline this version.
This changes the ktlint plugin to the Spotless Gradle plugin with ktlint support. Spotless also allows to run other formatters, so this comes with Markdown, KTS and misc rules configured.
This spares the Java formatter due to it's massive changeset. A simple rule matching most of current Java code style is:
Due to some issues with ktlint 0.48.x it is still using 0.47.1. Problems expected to be fixed in ktlint 0.49.0
Closes #6605