D.marin/ktlint#1081
Conversation
233275d to
01e5722
Compare
xgouchet
left a comment
There was a problem hiding this comment.
Nice job. One quick thought, we might want to remove the ktLint Gradle plugin which mentions a different version of ktLint and might return different reports when ran locally
Codecov Report
@@ Coverage Diff @@
## develop #1081 +/- ##
===========================================
- Coverage 83.19% 83.16% -0.03%
===========================================
Files 272 272
Lines 9279 9279
Branches 1494 1494
===========================================
- Hits 7719 7716 -3
- Misses 1143 1145 +2
- Partials 417 418 +1
|
Indeed, updated |
| image: "registry.ddbuild.io/mobile/images/ktlint:v0.1.0" | ||
| script: | ||
| - GRADLE_OPTS="-Xmx2560m" ./gradlew :ktlintCheckAll --stacktrace --no-daemon | ||
| - echo "Using Ktlint version $(ktlint --version)" |
There was a problem hiding this comment.
it also means we have to keep local ktlint version in sync with the version used in the image (because the rules may be different)?
There was a problem hiding this comment.
Yes, exactly.
In a second step, we might find a way to ensure this condition or make it easier to upgrade/be in sync. Any ideas?
There was a problem hiding this comment.
I guess the only way is to just build a new docker image with a different tag (or have a fat docker image with multiple ktlint versions embedded).
4915e92 to
2716d12
Compare
2716d12 to
3fa28c1
Compare
| classpath(libs.androidToolsGradlePlugin) | ||
| classpath(libs.kotlinGradlePlugin) | ||
| classpath(libs.kotlinSPGradlePlugin) | ||
| classpath(libs.ktLintGradlePlugin) |
There was a problem hiding this comment.
I'm wondering what the flow will be. Before I was running ktlintFormat before pushing to git - at which step formatting will be done now? Also sometimes ktlintFormat fails to do the job, like in case of too long lines - in that case some manual changes were needed.
There was a problem hiding this comment.
You ca still run ktlint -F "**/*.kt" "**/*.kts" '!**/build/generated/**' '!**/build/kspCaches/**' or make it a pre-commit hook. Will behave the same.
However I guess I should update the doc with the current required ktlint version (0.45.1)
There was a problem hiding this comment.
but in this case I need to install ktlint CLI on my machine manually, do I get it right? Or you are using the Dockerimage for that which has a project folder mounted to it?
There was a problem hiding this comment.
I personally use the local ktlint CLI on my machine (the gradle plugin was just already a wrapper around the CLI on your machine no?)
There was a problem hiding this comment.
No, Gradle plugin is not a wrapper for the existing ktlint, I don't have ktlint installed on my machine. But I see the proposed approach now :)
| # launches the detekt static analysis for all modules | ||
| ./gradlew detektAll | ||
|
|
||
| # launches the ktlint format check for all modules |
There was a problem hiding this comment.
Can we mention the ktlint cli here instead to make sure contributors know that this is a check they should use:
ktlint -F "**/*.kt" "**/*.kts" '!**/build/generated/**' '!**/build/kspCaches/**'| There is also a gradle task that you can use to automatically format the code following the | ||
| required styling rules: | ||
|
|
||
| ```console | ||
|
|
||
| ./gradlew :dd-sdk-android:ktlintFormat | ||
|
|
| import kotlinx.coroutines.launch | ||
| import kotlinx.coroutines.runBlocking | ||
| import kotlinx.coroutines.withContext | ||
| import kotlin.coroutines.CoroutineContext |
There was a problem hiding this comment.
strange that kotlin is places below kotlinx, but okay
What does this PR do?
Update Ktlint to 0.45.1 and use a dedicated runner image
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)