-
Notifications
You must be signed in to change notification settings - Fork 503
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
adding disabledRules=["experimental:argument-list-wrapping"] triggers IndexOutOfBoundsException #1045
Comments
I could not reproduce to get exactly [DEBUG] Checking android-mdc-theming/app/src/main/java/com/ricknout/mdctheming/theming/ThemingActivity.kt
[DEBUG] Internal Error (experimental:multiline-if-else)
com.pinterest.ktlint.core.RuleExecutionException: java.lang.ClassCastException: org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement cannot be cast to org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement
at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:320)
at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:27)
at com.pinterest.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:247)
at com.pinterest.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:27)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:225)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:246)
at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:27)
at com.pinterest.ktlint.core.KtLint.format(KtLint.kt:299)
at com.pinterest.ktlint.internal.FileUtilsKt.formatFile(FileUtils.kt:99)
at com.pinterest.ktlint.KtlintCommandLine.process(Main.kt:358)
at com.pinterest.ktlint.KtlintCommandLine.access$process(Main.kt:124)
at com.pinterest.ktlint.KtlintCommandLine$lintFiles$2$1.call(Main.kt:281)
at com.pinterest.ktlint.KtlintCommandLine$lintFiles$2$1.call(Main.kt:124)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement cannot be cast to org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement
at com.pinterest.ktlint.ruleset.experimental.MultiLineIfElseRule.autocorrect(MultiLineIfElseRule.kt:53)
at com.pinterest.ktlint.ruleset.experimental.MultiLineIfElseRule.visit(MultiLineIfElseRule.kt:39)
at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:306)
... 29 more
android-mdc-theming/app/src/main/java/com/ricknout/mdctheming/bottomappbar/BottomAppBarActivity.kt:0:0: Internal Error (experimental:multiline-if-else). Please create a ticket at https://github.com/pinterest/ktlint/issues (if possible, provide the source code that triggered an error) (cannot be auto-corrected) () @phileo is this actual exception you see on running KtLint? |
@Tapchicoma I retried ktlint on that project, and you're right, it does not repro the Attached is a Test Class that I crafted which will reproduce the |
I can reproduce the issue with the TestClass example. In this case the "-a" flag is important as the error is not thrown when running without that flag. Stacktrace:
|
In case my
When running This is confirmed by disabling the If I run with
Those messages need to be investigated further. I expect they are caused by having non consistent indentation logic in the IndentationRule and the ArgumentListWrappingRule. |
Only the indentation rule should emit warnings about incorrect indentation to avoid conflicting warnings from different rules about the indentation of the exact same line. However, those other rules should still fix the indentation as good as they can for the case that the indent rule is not run at all. Closes pinterest#1267, pinterest#1119, pinterest#1045
Closed by #1284 |
Steps to Reproduce
then run the following from command line:
ktlint -F --experimental --android --verbose --debug --disabled_rules=final-newline,parameter-list-wrapping,argument-list-wrapping,no-wildcard-imports,max-line-length,experimental:package-name
The text was updated successfully, but these errors were encountered: