https://kotlinlang.org logo
Title
r

Ryan Sang

03/21/2023, 9:06 PM
How do
kotlinter
or
ktlint-gradle
detect the
.editorconfig
file? Using plain
ktlint
I have no issues but with either plugin it doesn’t seem to respect the
.editorconfig
(e.g. uses experimental rules when I have experimental rules disabled, confirmed with plain
ktlint
). My
.editorconfig
lives in the root directory of the project.
e

Emil Kantis

03/21/2023, 9:07 PM
Never had that issue.. How are you applying the plugin?
m

mateusz.kwiecinski

03/21/2023, 9:17 PM
Have you tried killing the deamon wtih
./gradlew --stop
after modifying editorconfig file? I recall there was an issue where editorconfig content was cached by ktlint and both plugins weren't properly reseting ktlint caches 👀
j

jlleitschuh

03/21/2023, 9:18 PM
IIRC, we fixed that by adding the
.editorconfig
file as a task input
m

mateusz.kwiecinski

03/21/2023, 9:23 PM
yeah, but it's required the task to be run incrementally: https://github.com/JLLeitschuh/ktlint-gradle/blob/83382192c0c3d3dede7b7ab323c1e74f[…]tlin/org/jlleitschuh/gradle/ktlint/tasks/BaseKtLintCheckTask.kt I don't remember the exact scenario 🤔 Wouldn't it break if the task continues to fail? 1. You run the task, ktlint caches editorconfig, the task fails 2. You adjust the editorconfig content 3. Run the task again, it is not incremental (since the last execution has failed), editorconfig caches are not invalidated 4. As the result ktlint doesn't respect updated settings on the second run
j

jlleitschuh

03/21/2023, 9:24 PM
@wakingrufus ^
w

wakingrufus

03/21/2023, 9:25 PM
👀 i can look into this
m

mateusz.kwiecinski

03/21/2023, 9:29 PM
If you're looking at the code around listening for editorconfig changes, you may also want to look at the bug I reported: https://github.com/JLLeitschuh/ktlint-gradle/issues/575 😛
r

Ryan Sang

03/21/2023, 9:29 PM
gradlew --stop
seems to have fixed the issue. Thanks!
m

mateusz.kwiecinski

03/21/2023, 9:33 PM
I can also mention that the plugin still uses the KtLint.trimMemory() to reset the editorconfig caches and traverses through filesystem manually. Ktlint added dedicated apis for that: https://github.com/pinterest/ktlint/pull/1659/files - the
editorConfigFilePaths
and
reloadEditorConfigFile