It seems that adding ktlint_code_style to .editorconfig causes a ClassCastException.
Steps to Reproduce
Add this to .editorconfig:
[*.{kt,kts}]
ktlint_code_style = official
(I am not sure if it matters, but I have tested this with both ktlint 0.48.2 and 0.49.1.)
Note that this problem also exists if setting to ktlint_official (what ktlint 0.49.1 uses) instead of official (what ktlint 0.48.2 uses).
Expected behavior
That ./gradlew clean diktatCheck runs without throwing an exception.
Observed behavior
$ ./gradlew clean diktatCheck
> Task :simpleCykParser:diktatCheck
Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.ClassCastException: class java.lang.String cannot be cast to class com.pinterest.ktlint.core.api.DefaultEditorConfigProperties$CodeStyleValue (java.lang.String is in module java.base of loader 'bootstrap'; com.pinterest.ktlint.core.api.DefaultEditorConfigProperties$CodeStyleValue is in unnamed module of loader 'app')
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at com.pinterest.ktlint.internal.KtlintCommandLine.parallel(KtlintCommandLine.kt:578)
at com.pinterest.ktlint.internal.KtlintCommandLine.parallel$default(KtlintCommandLine.kt:536)
at com.pinterest.ktlint.internal.KtlintCommandLine.lintFiles(KtlintCommandLine.kt:283)
at com.pinterest.ktlint.internal.KtlintCommandLine.run(KtlintCommandLine.kt:235)
at com.pinterest.ktlint.Main.main(Main.kt:31)
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class com.pinterest.ktlint.core.api.DefaultEditorConfigProperties$CodeStyleValue (java.lang.String is in module java.base of loader 'bootstrap'; com.pinterest.ktlint.core.api.DefaultEditorConfigProperties$CodeStyleValue is in unnamed module of loader 'app')
at com.pinterest.ktlint.core.api.UsesEditorConfigProperties$DefaultImpls.getEditorConfigValue(UsesEditorConfigProperties.kt:50)
at com.pinterest.ktlint.core.internal.VisitorProvider.getEditorConfigValue(VisitorProvider.kt:17)
at com.pinterest.ktlint.core.internal.VisitorProvider.isNotDisabled(VisitorProvider.kt:132)
at com.pinterest.ktlint.core.internal.VisitorProvider.visitor$ktlint_core(VisitorProvider.kt:43)
at com.pinterest.ktlint.core.internal.VisitorProvider.visitor$ktlint_core$default(VisitorProvider.kt:37)
at com.pinterest.ktlint.core.KtLint.lint(KtLint.kt:140)
at com.pinterest.ktlint.internal.FileUtilsKt.lintFile(FileUtils.kt:174)
at com.pinterest.ktlint.internal.KtlintCommandLine.process(KtlintCommandLine.kt:384)
at com.pinterest.ktlint.internal.KtlintCommandLine.access$process(KtlintCommandLine.kt:48)
at com.pinterest.ktlint.internal.KtlintCommandLine$lintFiles$3.invoke$lambda-1(KtlintCommandLine.kt:274)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Environment information
diktat version: 1.2.5
build tool (maven/gradle): gradle
how is diktat run (CLI, plugin, etc.): plugin
kotlin version: 1.8.10
operating system: Linux
link to a project (if your project is public): Not yet public
Describe the bug
It seems that adding
ktlint_code_style
to.editorconfig
causes aClassCastException
.Steps to Reproduce
Add this to
.editorconfig
:(I am not sure if it matters, but I have tested this with both ktlint 0.48.2 and 0.49.1.)
Note that this problem also exists if setting to
ktlint_official
(what ktlint 0.49.1 uses) instead ofofficial
(what ktlint 0.48.2 uses).Expected behavior
That
./gradlew clean diktatCheck
runs without throwing an exception.Observed behavior
Environment information