Skip to content
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

Load Reporters dynamically, using provided ktlint version #294

Open
wants to merge 4 commits into
base: run_lint_with_process_isolation
Choose a base branch
from

Conversation

mateuszkwiecinski
Copy link
Contributor

Follow up on #279 (comment) - which moves all ktlint classes to be loaded in process isolation, within workers. The same way RuleSetProviderV2s are.

Comment on lines +24 to 32
internal fun reporterPathFor(reporterType: ReporterType, output: File, relativeRoot: File) = when (reporterType) {
ReporterType.Checkstyle,
ReporterType.Html,
ReporterType.Json,
ReporterType.Plain,
-> output.toRelativeString(base = relativeRoot)

ReporterType.Sarif -> output.absolutePath
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mindlessly copied existing logic with those paths 👀 Old logic did an instance checks, but the plugin now doesn't know what any of Reporter implementations

Comment on lines 111 to 119
assertTrue(reportContent.contains(""""version": "0.47.0""""))
assertTrue(reportContent.contains(""""semanticVersion": "0.47.0""""))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed ktlint version appears in generated report so I decided to use to verify the behavior changes when the ktlintVersion gets overriden

Comment on lines +119 to +143
private fun expectedEmptyPlain() = ""

// language=xml
private fun expectedEmptyCheckstyle() = """
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="8.0">
</checkstyle>

""".trimIndent()

// language=html
private fun expectedEmptyHtml() = """
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" />
<meta http-equiv="Content-Type" Content="text/html; Charset=UTF-8">
<style>
body {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asserting on file content isn't necessarily the most reliable way to ensure proper behavior, and we probably should only compare smaller parts of the content. I wanted to avoid making decisions what to test here specifically, and decided to start with full-content comparison and then migrate to either smaller chunks or start parsing the reports? Ideas are welcome

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems a little heavy. If we just check the content for a small known snippet, what's the real chance we'd have a false positive test pass?

@mateuszkwiecinski mateuszkwiecinski marked this pull request as ready for review October 24, 2022 08:25
@mateuszkwiecinski mateuszkwiecinski force-pushed the separate_reporters branch 2 times, most recently from 2947c77 to 55aad23 Compare January 5, 2023 06:38
@mateuszkwiecinski mateuszkwiecinski force-pushed the separate_reporters branch 3 times, most recently from 2540e51 to 56a2c33 Compare January 20, 2023 22:06
This test should use any other _supported_ ktlint version, the only requirement is it doesn't match the one used by the plugin
Copy link
Owner

@jeremymailen jeremymailen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Let's get this one merged into the bigger change along with #289 and we get that big piece landed for 4.0.0.

Comment on lines +119 to +143
private fun expectedEmptyPlain() = ""

// language=xml
private fun expectedEmptyCheckstyle() = """
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="8.0">
</checkstyle>

""".trimIndent()

// language=html
private fun expectedEmptyHtml() = """
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" />
<meta http-equiv="Content-Type" Content="text/html; Charset=UTF-8">
<style>
body {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems a little heavy. If we just check the content for a small known snippet, what's the real chance we'd have a false positive test pass?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants