I am having a weird issue when running ktlint loca...
# ktlint
d
I am having a weird issue when running ktlint locally (using the gradle plugin) where check and format do not line up
Copy code
daz@daz:/source/source/well/consumer-android-ui-2$ git status
On branch MOB-310-integrate-ktlint
Your branch is up to date with 'origin/MOB-310-integrate-ktlint'.

nothing to commit, working tree clean
daz@daz:/source/source/well/consumer-android-ui-2$ ./gradlew :app:ktlintDebugSourceSetCheck
Configuration on demand is an incubating feature.

BUILD SUCCESSFUL in 919ms
16 actionable tasks: 1 executed, 15 up-to-date
(failed reverse-i-search)`forma': git reset --hard origin/MOB-1190-calculate-height-^Cr-list-items
daz@daz:/source/source/well/consumer-android-ui-2$ ./gradlew :app:ktlintDebugSourceSetFormat
Configuration on demand is an incubating feature.

BUILD SUCCESSFUL in 1s
16 actionable tasks: 2 executed, 14 up-to-date
daz@daz:/source/source/well/consumer-android-ui-2$ git status
On branch MOB-310-integrate-ktlint
Your branch is up to date with 'origin/MOB-310-integrate-ktlint'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   app/src/debug/java/co/foo/data/session/LocalSessionDataSource.kt
        modified:   app/src/debug/java/co/foo/util/FlipperUtil.kt

no changes added to commit (use "git add" and/or "git commit -a")
j
Which Gradle Plugin?
I believe there are two
Three if you include spotless
d
the one you write big dog
this is my config
Copy code
ktlint {
    version.set("0.45.2")
    android.set(true)
    reporters {
        reporter(ReporterType.HTML)
    }
    outputColorName.set("RED")
    disabledRules.set(setOf("no-wildcard-imports"))
}
j
That's probably mine then
d
Copy code
id("org.jlleitschuh.gradle.ktlint") version Versions.ktlint
const val ktlint = "10.2.1"
j
So, running 'format' doesn't update the sources?
d
format does
but check is not failing
Copy code
daz@daz:/source/source/well/consumer-android-ui-2$ ./gradlew :app:ktlintDebugSourceSetCheck
Configuration on demand is an incubating feature.

BUILD SUCCESSFUL in 919ms
Copy code
daz@daz:/source/source/well/consumer-android-ui-2$ ./gradlew :app:ktlintDebugSourceSetFormat
Configuration on demand is an incubating feature.

BUILD SUCCESSFUL in 1s
16 actionable tasks: 2 executed, 14 up-to-date
daz@daz:/source/source/well/consumer-android-ui-2$ git status
On branch MOB-310-integrate-ktlint
Your branch is up to date with 'origin/MOB-310-integrate-ktlint'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   app/src/debug/java/co/foo/data/session/LocalSessionDataSource.kt
        modified:   app/src/debug/java/co/foo/util/FlipperUtil.kt
and it's weird because
:app:ktlintDebugSourceSetCheck
is failing in CI
but not locally...
maybe it is an IDE config or something
s
when it fails on CI, what rule(s) are failling?
j
I don't know what the 'debug' variant of the task does, I'm not familiar with it
Consider only running the high-level tasks, format and check, not the ones on specific source sets
The ones on specific source sets aren't meant to be run in isolation IIRC
d
Copy code
> Task :app:ktlintDebugSourceSetCheck FAILED
/bitrise/src/app/src/debug/java/co/[REDACTED]/[REDACTED]app/data/session/LocalSessionDataSource.kt:1:1 File must end with a newline (\n)
/bitrise/src/app/src/debug/java/co/[REDACTED]/[REDACTED]app/util/FlipperUtil.kt:1:1 File must end with a newline (\n)
/bitrise/src/app/src/debug/java/co/[REDACTED]/[REDACTED]app/util/FlipperUtil.kt:29:19 Missing newline after ","
j
What happens when you run the format task?
d
it formats the files
just like what I put here
Copy code
modified:   app/src/debug/java/co/foo/data/session/LocalSessionDataSource.kt
        modified:   app/src/debug/java/co/foo/util/FlipperUtil.kt
didn't realize we weren't supposed to run the tasks independently
j
So, I don't understand the problem, does format fix the problem? Or no?
Opening an issue may help, I'm not understanding the full issue. There's unfortunately not enough context here
d
the problem is format fixes the problem, but check does not find the problems that format fixes
j
Oh
d
CHECK = no find problem FORMAT = formats problem
j
Hrm...
d
im new to all of this, i could be breaking something
thanks for the hints
j
There's a bug in this area, it has to do with caching, having your inputs be the same as your outputs cause problems for Gradle. There's only so much we can do in this area unfortunately
d
the inputs/outputs being files?
j
Yea, the source code files
d
who makes this gradle trash?
😂 1
jkjkjk 😉
rather have some gradle than ant, maven, etc
j
I used to 🙂
d
i know, that is why i was teasing you
😛