Hey idk if y'all are familiar with this static ana...
# ktlint
Hey idk if y'all are familiar with this static analysis plugin but I'm using it as a wrapper to run KtLint and detekt: https://github.com/novoda/gradle-static-analysis-plugin I noticed that when I use this Detekt outputs with a specific color for the error making it is easy to find in our logs but KtLint does not. Is there any flag or configuration I can set to do this? I mentioned that plugin because it might not be easy if I'm not calling KtLint directly.
Thanks! It looks like the gradle plugin I use for KtLint has that as `coloredOutput`: https://github.com/JLLeitschuh/ktlint-gradle/blob/master/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/BaseKtlintCheckTask.kt#L141 So I just had to do this:
Copy code
staticAnalysis {
    ktlint {
        // ...
        outputToConsole = true
        coloredOutput = true
That should be true by default so I don't know why I'm not seeing it but I think I will have to take it up with that plugin. Thanks for getting me this far, though!
though will add such info to extension property description, as it could be misleading ๐Ÿ‘
They do have that somewhere one sec
er yes the link you sent is something I found.
Wouldn't I see that printed in the console though? Not sure where that info log goes to. I don't think the console type is plain, because Detekt is able to print its errors in colored output...
on info level it would be visible (you need to add
to gradle run)
From https://docs.gradle.org/current/userguide/command_line_interface.html#sec:command_line_customizing_log_format:
Set to plain to generate plain text only. This option disables all color and other rich output in the console output. This is the default when Gradle is not attached to a terminal.
That is why colored output is disabled
Hmm even with
passed through, I don't see that error printed anywhere. I'm able to recreate on a separate project from work so I'm going to submit an issue to them and see if I learn anything. Will link it here when I do if you want to follow along.
actually I am a developer for this plugin, so submitting an issue would be enough ๐Ÿ™‚
oh ๐Ÿ˜‚
So sorry
no problem ๐Ÿ™‚
hmm you know what I think I'm at fault here. My sample project and my work project weren't configured correctly. One indeed was using a plain Reporter. I'm so sorry to have wasted your time lol
no problem, was happy to help ๐Ÿ‘
The other project is colored, but it's like a gray ish color and that makes it not noticeable to me, unlike Detekt which gives me more of a yellow output. I suppose that isn't customizable?
nope, coloring itself is done by ktlint
yellow output, I would say it should not be like this on plain console
Here's a detekt error in my console
This is how I get it from KtLint lol
I would say Detekt behaves wrong in this case
Why is that? The contrast is much better, so as I'm scrolling through logs it makes it very easy for me to find what I did wrong.
it is dark yellow color :)
This option disables all color and other rich output in the console output.
console - showing colors are ok
Hmm I think I need to keep digging because then I'm not sure I have the right problem here after all. I'm guessing that this is working right, since Detekt and a few other things do print colors in this console. Perhaps it is just the color from KtLint that I don't like, and I never realized this darker gray was actually being colored.
try to run the build with
option and check ktlint coloring
yep it's the same
you could write your own reporter with nice coloring ๐Ÿ™‚
Yeah I'm gonna check to see if anyone else has complained about this in an issue and if not I may have to go that route. Sorry for all this I really did go down the wrong rabbit hole sorry to bring you with me hahaha
Thanks so much for your help! I still learned a lot of good things that will help me debug in the future. ๐Ÿ™‚
I've made a PR to support this! https://github.com/pinterest/ktlint/pull/585
๐Ÿ‘ 1