-
-
Notifications
You must be signed in to change notification settings - Fork 768
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
Don't use System.out in the ProgressListeners #2495
Conversation
Lets add |
99163da
to
b0715b0
Compare
What do you think about |
b0715b0
to
e3689be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the direction of noise-less tests and standard output channels 👍
|
||
val outPrinter: PrintStream | ||
|
||
val errPrinter: PrintStream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both printers will need kdoc to pass ci
@@ -51,7 +51,7 @@ class SingleRuleRunner( | |||
val result = DetektFacade.create( | |||
settings, | |||
listOf(provider), | |||
listOf(DetektProgressListener()) | |||
listOf(DetektProgressListener(outPrinter)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
listOf(DetektProgressListener(outPrinter)) | |
listOf(DetektProgressListener().apply { init(settings) }) |
detekt-cli/src/main/kotlin/io/gitlab/arturbosch/detekt/cli/DetektProgressListener.kt
Outdated
Show resolved
Hide resolved
constructor() | ||
|
||
constructor(outPrinter: PrintStream) { | ||
this.outPrinter = outPrinter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets just use the init
function instead introducing two constructors. I've made suggestions on the two usages.
import org.jetbrains.kotlin.psi.KtFile | ||
import java.io.PrintStream | ||
|
||
class DetektProgressListener : FileProcessListener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this copy and just use the real progress listener from cli?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, lets remove this whole class alltogether as the dots are not really useful for the generator :)
@@ -13,14 +13,14 @@ class Runner( | |||
private val outPrinter: PrintStream, | |||
private val errPrinter: PrintStream | |||
) { | |||
private val listeners = listOf(DetektProgressListener()) | |||
private val listeners = listOf(DetektProgressListener(outPrinter)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets remove this listener. The generator output is no realy useful.
6ba1366
to
a5c4c8f
Compare
…ektProgressListener.kt Co-Authored-By: Artur Bosch <arturbosch@gmx.de>
a5c4c8f
to
9fbc108
Compare
detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/SetupContext.kt
Outdated
Show resolved
Hide resolved
detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/SetupContext.kt
Outdated
Show resolved
Hide resolved
…upContext.kt Co-Authored-By: Artur Bosch <arturbosch@gmx.de>
…upContext.kt Co-Authored-By: Artur Bosch <arturbosch@gmx.de>
This PR is not ready because I have a problem here. TheDetektProgessListener
is loaded by the ServiceLoader so I can't add thePrintStream
as a constructor parameter. I need to get it later usinginit(Config)
orinit(SetupContext)
. But neigther of them has that reference.Should I add it to any of them? Or should I create a newinit
that provides bothPrintStream
?This PR is part of a serie of PRs related with how we manage the output.
The main ideas:
PrinterStream.println
instead ofprintln
printerStream
. Because that is the same as useprintln
.PrinterStream
to print output we can useNullPrinterStream
or other types ofPrinterStream
so we don't print to the stdout when we run tests. With this we can reduce the log size related with tests about 40%.