https://kotlinlang.org logo
#ktlint
Title
# ktlint
p

Paul Dingemans

08/04/2022, 11:07 AM
KtLint does not magically update behind the scenes. If the version and configuration are unchanged since last successful run than the difference must be in the code. I am not familiar enough with the plugin to say something about it.
👍 2
p

Piotr Krzemiński

08/04/2022, 6:17 PM
Can I somehow get debug info on what ktlint does, to go forward with troubleshooting my problem? E. g. to learn what rules are enabled
p

Paul Dingemans

08/04/2022, 6:29 PM
Yeah, use option “-v” (or “--verbose”).
p

Paul Woitaschek

08/04/2022, 8:41 PM
Do you use the cli or some Gradle plugin?
I didn't have time to test the verbose mode yet
So, the log showed not all files being processed. Can it be because one Gradle task creates the files, and
org.gradle.parallel=true
or
org.gradle.caching=true
makes Ktlint not see all files?
These two settings were added 3 days ago, approx. when the issue started to happen, so there's high correlation
@Zongle Wang FYI
Removing these two options solved my issue, but it's still something worth looking at within probably the Gradle plugin. FYI @jlleitschuh
p

Paul Woitaschek

08/05/2022, 10:14 AM
And are you sure you correctly declared the outputs and task order?
p

Piotr Krzemiński

08/05/2022, 10:15 AM
No :) My knowledge about Gradle is limited
p

Paul Woitaschek

08/05/2022, 10:16 AM
Can it be because one Gradle task creates the files
It sounds like they are generated at build time?
p

Piotr Krzemiński

08/05/2022, 10:28 AM
Yes - adding a task dependency so that ktlint runs after the file generation task should do the job right?
p

Paul Woitaschek

08/05/2022, 10:29 AM
But why would you ktlint generated Code in the first place?
p

Piotr Krzemiński

08/05/2022, 10:30 AM
So that it's more readable when someone browses its source
p

Paul Woitaschek

08/05/2022, 10:30 AM
Ah wow. Okay that's an interesting requirement
Can you post the skeleton of your Gradle task that generates?
p

Piotr Krzemiński

08/05/2022, 10:31 AM
Also, we keep these in version control for now, to exactly see what changes over time. Thanks to formatting, diffs are cleaner. One day we may remove it from VCS
p

Paul Woitaschek

08/05/2022, 10:37 AM
The correct way would to not use an application plugin but instead a gradle task that declares inputs and outputs.
It might work do declare proper task outputs here, i.e. outputs.dir(project.path….)
p

Piotr Krzemiński

08/05/2022, 10:42 AM
Thanks, I'll tinker around it in spare moment. FYI @jmfayard
j

jmfayard

08/05/2022, 11:01 AM
To be honest, I would rather not reformat the generated code with ktlint and configure ktlint/detekt to ignore it.
p

Piotr Krzemiński

08/05/2022, 11:03 AM
Yes, it's a possible trade-off
p

Paul Woitaschek

08/05/2022, 11:07 AM
I would absolutely do that if I maintained that. ^^
p

Piotr Krzemiński

08/05/2022, 11:14 AM
Thanks for the discussion!
4 Views