When spotlessKotlin fails it ouputs a large stacktrace which makes it hard to figure out which line number failed.
It would be nice to have an output similar to the spotlessJava task but at the very least to include the line numbers where the task failed.
Here is an example stacktrace from a failed kotlin task.
> Task :app:spotlessKotlin FAILED
Step 'ktlint' found problem in 'app/src/main/java/com/foo/bar/Foo.kt':
Unexpected indentation (17) (it should be 16)
java.lang.AssertionError: Unexpected indentation (17) (it should be 16)
at com.diffplug.spotless.kotlin.KtLintStep$State.lambda$createFormat$0(KtLintStep.java:110)
at com.sun.proxy.$Proxy115.invoke(Unknown Source)
at com.github.shyiko.ktlint.core.KtLint$format$2$1.invoke(KtLint.kt:357)
at com.github.shyiko.ktlint.core.KtLint$format$2$1.invoke(KtLint.kt:36)
at com.github.shyiko.ktlint.ruleset.standard.IndentationRule.visit(IndentationRule.kt:41)
at com.github.shyiko.ktlint.core.KtLint$format$2.invoke(KtLint.kt:355)
at com.github.shyiko.ktlint.core.KtLint$format$2.invoke(KtLint.kt:36)
at com.github.shyiko.ktlint.core.KtLint$visitor$2$1.invoke(KtLint.kt:201)
at com.github.shyiko.ktlint.core.KtLint$visitor$2$1.invoke(KtLint.kt:36)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:487)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
at com.github.shyiko.ktlint.core.KtLint.visit(KtLint.kt:488)
at com.github.shyiko.ktlint.core.KtLint.access$visit(KtLint.kt:36)
at com.github.shyiko.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:199)
at com.github.shyiko.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:36)
at com.github.shyiko.ktlint.core.KtLint.format(KtLint.kt:350)
at com.github.shyiko.ktlint.core.KtLint.format(KtLint.kt:279)
at sun.reflect.GeneratedMethodAccessor136.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.diffplug.spotless.kotlin.KtLintStep$State.lambda$createFormat$1(KtLintStep.java:124)
at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:78)
at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:76)
at com.diffplug.spotless.Formatter.compute(Formatter.java:230)
at com.diffplug.spotless.Formatter.isClean(Formatter.java:167)
at com.diffplug.gradle.spotless.SpotlessTask.check(SpotlessTask.java:263)
at com.diffplug.gradle.spotless.SpotlessTask.performAction(SpotlessTask.java:205)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
...
I would be happy to work on this but I'm not quite sure what the best way to format the output would be. I see that this exception is thrown on KtLintStep.java:110 and that the LintError object includes the line and column number.
Is there a better way to throw the exception other than AssertionError?
When spotlessKotlin fails it ouputs a large stacktrace which makes it hard to figure out which line number failed.
It would be nice to have an output similar to the spotlessJava task but at the very least to include the line numbers where the task failed.
Here is an example stacktrace from a failed kotlin task.
I would be happy to work on this but I'm not quite sure what the best way to format the output would be. I see that this exception is thrown on KtLintStep.java:110 and that the
LintErrorobject includes the line and column number.Is there a better way to throw the exception other than
AssertionError?