-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add support for custom ktlint reporters #258
Conversation
dc455b3
to
a780e71
Compare
plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/BaseKtlintCheckTask.kt
Outdated
Show resolved
Hide resolved
plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/BaseKtlintCheckTask.kt
Outdated
Show resolved
Hide resolved
plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/reporter/CustomReporter.kt
Show resolved
Hide resolved
...ter-creating/src/main/resources/META-INF/services/com.pinterest.ktlint.core.ReporterProvider
Outdated
Show resolved
Hide resolved
Can you put a README in Do we need to explain to developers that if they side effect change other files outside of the input and output we won't see their changes and it won't get captured in Gradle's "out of date" checking. Also, just checking, how do custom reporters work with the Gradle Build Cache? |
a780e71
to
437dece
Compare
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Add test for 3rd party reporters. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Maybe I misunderstand you, but why we need to add README how to create ktlint reporter? It should be in a ktlint project.
Can you explain here?
Should work, as all reporters produces task |
92e76e3
to
ce38cea
Compare
Added test, that checks if reporters are relocatable. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
For example: If you side effect other files in your report, you will need to manually add those side affected files as outputs of the Gradle task. Failure to do so will mean that Gradle will be unable to fully detect all file changed by the task and thus may incorrectly mark your tasks as "up-to-date" when they actually aren't. |
Sorry, still don't get it fully - how can consume "side-effect" output file? All 3rd party output reports are added to task outputs, so if they will be removed or modified - task will re-run again. |
Example: class CsvReporter(
private val out: PrintStream
) : Reporter {
override fun onLintError(file: String, err: LintError, corrected: Boolean) {
val line = "$file;${err.line};${err.col};${err.ruleId};${err.detail};$corrected"
out.println(line)
File("some_other_file.txt").write(line) // Side effect: `some_other_file.txt` won't be captued as an "output"
}
} |
Now I got it. Yeah, such "side effect" should be mentioned in README. Not sure if it should be in this project or ktlint? 🤔 |
Not sure. Both? |
Is this still in development? I was looking into the idea of a custom reporter to tweak the colored output for KtLint, being discussed here: pinterest/ktlint#582 Am I unable to implement a custom reporter without this PR being merged? |
Yes, I am planning to finish it before next release (pretty soon). Until then, unfortunately, you can't use custom reporter with this plugin. |
Thanks for the update! Ping me if I can provide assistance in any way. :) |
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
To group reporters and support custom one changed DSL to be more nice. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
It is obvious from context that file extension is related to reporter. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
… state. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
@JLLeitschuh this PR is ready to be reviewed again |
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.
LGTM!
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Closes #125