-
Notifications
You must be signed in to change notification settings - Fork 64
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
D.marin/ktlint #1081
D.marin/ktlint #1081
Conversation
233275d
to
01e5722
Compare
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.
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 |
script: | ||
- GRADLE_OPTS="-Xmx2560m" ./gradlew :ktlintCheckAll --stacktrace --no-daemon | ||
- echo "Using Ktlint version $(ktlint --version)" |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -23,7 +23,6 @@ buildscript { | |||
classpath(libs.androidToolsGradlePlugin) | |||
classpath(libs.kotlinGradlePlugin) | |||
classpath(libs.kotlinSPGradlePlugin) | |||
classpath(libs.ktLintGradlePlugin) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :)
@@ -48,9 +48,6 @@ The whole project is covered by a set of static analysis tools, linters and test | |||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/**'
CONTRIBUTING.md
Outdated
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 | ||
|
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.
Same here
@@ -21,6 +19,8 @@ import kotlinx.coroutines.async | |||
import kotlinx.coroutines.launch | |||
import kotlinx.coroutines.runBlocking | |||
import kotlinx.coroutines.withContext | |||
import kotlin.coroutines.CoroutineContext |
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.
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)