ktlint-gradle icon indicating copy to clipboard operation
ktlint-gradle copied to clipboard

Improve error messages output when running tasks

Open peterMonteer opened this issue 6 years ago • 4 comments

Problem Description

When running ktlintCheck or ktlintFormat, if code style errors are found, the error message is not specific when the task fails, just mentioning a non-zero exit value after running the JavaExec in the runLint task.

This can cause some confusion and it's not very specific.

Suggested Solution:

Output error message when ktlintCheck finds code style errors: "Ktlint found X code styles errors, please fix them before continuing"

Output error message when ktlintFormat is not able to auto-correct: "Ktlint found X code styles errors that couldn't be auto-corrected, please fix them before continuing"

peterMonteer avatar Dec 12 '19 14:12 peterMonteer

@Tapchicoma do we even have the information required to do this?

JLLeitschuh avatar Feb 13 '20 21:02 JLLeitschuh

Generally, I think it is possible. Probably will require some changes in ktlint itself.

Tapchicoma avatar Feb 15 '20 12:02 Tapchicoma

I initially thought this was an issue with AGP, but it is actually a problem caused by KTLint-gradle plugin

This problem is very easy to reproduce. Just create any sample project using the new Project wizard in Android Studio 4.x and prepend an extra space before super.onCreate()

When building the sample project, the build window will report the following false failure:

Process 'command '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

However, if you run ./gradlew :app:ktlintAndroidTestSourceSetFormat you get back the syntax highlighting and line number of the failure, which is way more useful.

Is there a way to pipe the output of KTLint to the build window? Or alternatively, make KTLint failures behave like compile failures so that we can see the syntax highlighting and line number of the failure?

phileo99 avatar Aug 03 '20 20:08 phileo99

Even a message hinting about where the report files with further details can be found would be useful for Kotlin and/or Lint noobs like me

JCreswellENVRMNT avatar Sep 15 '21 22:09 JCreswellENVRMNT