From cf045123834b1783a9c9562d13579ca57abae080 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 2 May 2024 08:22:00 +0200 Subject: [PATCH 1/9] refactor(static-html): Use a shorter name for `ReportTableModel` This is more consistent with ORT's code base, which usually does not use the term "model" as a class name suffix. Signed-off-by: Frank Viernau --- .../{ReportTableModel.kt => ReportTable.kt} | 4 +- .../src/main/kotlin/ReportTableModelMapper.kt | 20 +++--- .../src/main/kotlin/StaticHtmlReporter.kt | 68 +++++++++---------- 3 files changed, 46 insertions(+), 46 deletions(-) rename plugins/reporters/static-html/src/main/kotlin/{ReportTableModel.kt => ReportTable.kt} (97%) diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTableModel.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt similarity index 97% rename from plugins/reporters/static-html/src/main/kotlin/ReportTableModel.kt rename to plugins/reporters/static-html/src/main/kotlin/ReportTable.kt index abca3a7d3d073..8e1249755af39 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTableModel.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt @@ -35,9 +35,9 @@ import org.ossreviewtoolkit.model.config.ScopeExclude import org.ossreviewtoolkit.model.licenses.ResolvedLicense import org.ossreviewtoolkit.utils.spdx.SpdxExpression -internal fun Collection.containsUnresolved() = any { !it.isResolved } +internal fun Collection.containsUnresolved() = any { !it.isResolved } -internal data class ReportTableModel( +internal data class ReportTable( /** * The [VcsInfo] for the scanned project. */ diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt index 448390d2727c3..9f3ecd0c61f17 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt @@ -30,19 +30,19 @@ import org.ossreviewtoolkit.model.config.Excludes import org.ossreviewtoolkit.model.config.ScopeExclude import org.ossreviewtoolkit.model.licenses.LicenseView import org.ossreviewtoolkit.model.orEmpty -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTableModel.DependencyRow -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTableModel.IssueTable -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTableModel.ProjectTable -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTableModel.ResolvableIssue -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTableModel.ResolvableViolation +import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.DependencyRow +import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.IssueTable +import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ProjectTable +import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ResolvableIssue +import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ResolvableViolation import org.ossreviewtoolkit.reporter.HowToFixTextProvider import org.ossreviewtoolkit.reporter.ReporterInput /** - * A mapper which converts an [OrtResult] to a [ReportTableModel]. + * A mapper which converts an [OrtResult] to a [ReportTable]. */ internal object ReportTableModelMapper { - fun map(input: ReporterInput): ReportTableModel { + fun map(input: ReporterInput): ReportTable { val analyzerResult = input.ortResult.analyzer?.result val excludes = input.ortResult.getExcludes() @@ -110,7 +110,7 @@ internal object ReportTableModelMapper { .map { it.toResolvableViolation(input.ortResult) } .sortedWith(VIOLATION_COMPARATOR) - return ReportTableModel( + return ReportTable( input.ortResult.repository.vcsProcessed, input.ortResult.repository.config, ruleViolations, @@ -200,9 +200,9 @@ private fun Map>.toIssueSummaryTable(type: IssueTable.Typ val rows = flatMap { (id, issues) -> issues.map { issue -> val resolvableIssue = issue.toResolvableIssue(input.ortResult, input.howToFixTextProvider) - ReportTableModel.IssueRow(resolvableIssue, id) + ReportTable.IssueRow(resolvableIssue, id) } - }.sortedWith(compareByDescending { it.issue.severity }.thenBy { it.id }) + }.sortedWith(compareByDescending { it.issue.severity }.thenBy { it.id }) return IssueTable(type, rows) } diff --git a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt index 3718c13fa09a0..8a44ba56951ce 100644 --- a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt +++ b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt @@ -47,9 +47,9 @@ import org.ossreviewtoolkit.model.config.RepositoryConfiguration import org.ossreviewtoolkit.model.config.ScopeExclude import org.ossreviewtoolkit.model.licenses.ResolvedLicenseLocation import org.ossreviewtoolkit.model.yamlMapper -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTableModel.IssueTable -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTableModel.ProjectTable -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTableModel.ResolvableIssue +import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.IssueTable +import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ProjectTable +import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ResolvableIssue import org.ossreviewtoolkit.reporter.Reporter import org.ossreviewtoolkit.reporter.ReporterInput import org.ossreviewtoolkit.utils.common.isValidUri @@ -87,7 +87,7 @@ class StaticHtmlReporter : Reporter { return listOf(outputFile) } - private fun renderHtml(reportTableModel: ReportTableModel): String { + private fun renderHtml(reportTable: ReportTable): String { val document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument() document.append.html { @@ -138,38 +138,38 @@ class StaticHtmlReporter : Reporter { h2 { +"Project" } div { - with(reportTableModel.vcsInfo) { + with(reportTable.vcsInfo) { +"Scanned revision $revision of $type repository $url" } } - if (reportTableModel.labels.isNotEmpty()) { - labelsTable(reportTableModel.labels) + if (reportTable.labels.isNotEmpty()) { + labelsTable(reportTable.labels) } - index(reportTableModel) + index(reportTable) - reportTableModel.ruleViolations?.let { + reportTable.ruleViolations?.let { ruleViolationTable(it) } - if (reportTableModel.analyzerIssueSummary.rows.isNotEmpty()) { - issueTable(reportTableModel.analyzerIssueSummary) + if (reportTable.analyzerIssueSummary.rows.isNotEmpty()) { + issueTable(reportTable.analyzerIssueSummary) } - if (reportTableModel.scannerIssueSummary.rows.isNotEmpty()) { - issueTable(reportTableModel.scannerIssueSummary) + if (reportTable.scannerIssueSummary.rows.isNotEmpty()) { + issueTable(reportTable.scannerIssueSummary) } - if (reportTableModel.advisorIssueSummary.rows.isNotEmpty()) { - issueTable(reportTableModel.advisorIssueSummary) + if (reportTable.advisorIssueSummary.rows.isNotEmpty()) { + issueTable(reportTable.advisorIssueSummary) } - reportTableModel.projectDependencies.forEach { (project, table) -> + reportTable.projectDependencies.forEach { (project, table) -> projectTable(project, table) } - repositoryConfiguration(reportTableModel.config) + repositoryConfiguration(reportTable.config) } } } @@ -177,7 +177,7 @@ class StaticHtmlReporter : Reporter { return document.serialize().normalizeLineBreaks() } - private fun getRuleViolationSummaryString(ruleViolations: List): String { + private fun getRuleViolationSummaryString(ruleViolations: List): String { val violations = ruleViolations.filterNot { it.isResolved }.groupBy { it.violation.severity } val errorCount = violations[Severity.ERROR].orEmpty().size val warningCount = violations[Severity.WARNING].orEmpty().size @@ -200,11 +200,11 @@ class StaticHtmlReporter : Reporter { } } - private fun DIV.index(reportTableModel: ReportTableModel) { + private fun DIV.index(reportTable: ReportTable) { h2 { +"Index" } ul { - reportTableModel.ruleViolations?.let { ruleViolations -> + reportTable.ruleViolations?.let { ruleViolations -> li { a("#$RULE_VIOLATION_TABLE_ID") { +getRuleViolationSummaryString(ruleViolations) @@ -212,31 +212,31 @@ class StaticHtmlReporter : Reporter { } } - if (reportTableModel.analyzerIssueSummary.rows.isNotEmpty()) { + if (reportTable.analyzerIssueSummary.rows.isNotEmpty()) { li { - a("#${reportTableModel.analyzerIssueSummary.id()}") { - +reportTableModel.analyzerIssueSummary.title() + a("#${reportTable.analyzerIssueSummary.id()}") { + +reportTable.analyzerIssueSummary.title() } } } - if (reportTableModel.scannerIssueSummary.rows.isNotEmpty()) { + if (reportTable.scannerIssueSummary.rows.isNotEmpty()) { li { - a("#${reportTableModel.scannerIssueSummary.id()}") { - +reportTableModel.scannerIssueSummary.title() + a("#${reportTable.scannerIssueSummary.id()}") { + +reportTable.scannerIssueSummary.title() } } } - if (reportTableModel.advisorIssueSummary.rows.isNotEmpty()) { + if (reportTable.advisorIssueSummary.rows.isNotEmpty()) { li { - a("#${reportTableModel.advisorIssueSummary.id()}") { - +reportTableModel.advisorIssueSummary.title() + a("#${reportTable.advisorIssueSummary.id()}") { + +reportTable.advisorIssueSummary.title() } } } - reportTableModel.projectDependencies.forEach { (project, projectTable) -> + reportTable.projectDependencies.forEach { (project, projectTable) -> li { a("#${project.id.toCoordinates()}") { +project.id.toCoordinates() @@ -259,7 +259,7 @@ class StaticHtmlReporter : Reporter { } } - private fun DIV.ruleViolationTable(ruleViolations: List) { + private fun DIV.ruleViolationTable(ruleViolations: List) { h2 { id = RULE_VIOLATION_TABLE_ID +getRuleViolationSummaryString(ruleViolations) @@ -288,7 +288,7 @@ class StaticHtmlReporter : Reporter { } } - private fun TBODY.ruleViolationRow(rowIndex: Int, ruleViolation: ReportTableModel.ResolvableViolation) { + private fun TBODY.ruleViolationRow(rowIndex: Int, ruleViolation: ReportTable.ResolvableViolation) { val cssClass = if (ruleViolation.isResolved) { "ort-resolved" } else { @@ -357,7 +357,7 @@ class StaticHtmlReporter : Reporter { } } - private fun TBODY.issueRow(rowId: String, rowIndex: Int, row: ReportTableModel.IssueRow) { + private fun TBODY.issueRow(rowId: String, rowIndex: Int, row: ReportTable.IssueRow) { val cssClass = when (row.issue.severity) { Severity.ERROR -> "ort-error" Severity.WARNING -> "ort-warning" @@ -457,7 +457,7 @@ class StaticHtmlReporter : Reporter { } } - private fun TBODY.projectRow(projectId: String, rowIndex: Int, row: ReportTableModel.DependencyRow) { + private fun TBODY.projectRow(projectId: String, rowIndex: Int, row: ReportTable.DependencyRow) { // Only mark the row as excluded if all scopes the dependency appears in are excluded. val rowExcludedClass = if (row.scopes.isNotEmpty() && row.scopes.all { it.value.isNotEmpty() }) "ort-excluded" else "" From fe407573a1ee64f590878ea155c26de81b1b0908 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 2 May 2024 08:27:02 +0200 Subject: [PATCH 2/9] refactor(static-html): Use a shorter name for `DependencyRow` Also move the class into `ProjectTable` to allow for that shorter name. Signed-off-by: Frank Viernau --- .../src/main/kotlin/ReportTable.kt | 108 +++++++++--------- .../src/main/kotlin/ReportTableModelMapper.kt | 4 +- .../src/main/kotlin/StaticHtmlReporter.kt | 2 +- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt index 8e1249755af39..7feb6df410226 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt @@ -82,7 +82,7 @@ internal data class ReportTable( /** * The dependencies of this project. */ - val rows: List, + val rows: List, /** * The path to the directory containing the definition file of the project, relative to the analyzer root, @@ -96,60 +96,60 @@ internal data class ReportTable( val pathExcludes: List ) { fun isExcluded() = pathExcludes.isNotEmpty() - } - - data class DependencyRow( - /** - * The identifier of the package. - */ - val id: Identifier, - - /** - * The remote artifact where the source package can be downloaded. - */ - val sourceArtifact: RemoteArtifact, - - /** - * The VCS information of the package. - */ - val vcsInfo: VcsInfo, - - /** - * The scopes the package is used in. - */ - val scopes: SortedMap>, - - /** - * The concluded license of the package. - */ - val concludedLicense: SpdxExpression?, - /** - * The licenses declared by the package. - */ - val declaredLicenses: List, - - /** - * The detected licenses aggregated from all [ScanResult]s for this package. - */ - val detectedLicenses: List, - - /** - * The effective license of the package derived from the licenses of the license sources chosen by a - * LicenseView, with optional choices applied. - */ - val effectiveLicense: SpdxExpression?, - - /** - * All analyzer issues related to this package. - */ - val analyzerIssues: List, - - /** - * All scan issues related to this package. - */ - val scanIssues: List - ) + data class Row( + /** + * The identifier of the package. + */ + val id: Identifier, + + /** + * The remote artifact where the source package can be downloaded. + */ + val sourceArtifact: RemoteArtifact, + + /** + * The VCS information of the package. + */ + val vcsInfo: VcsInfo, + + /** + * The scopes the package is used in. + */ + val scopes: SortedMap>, + + /** + * The concluded license of the package. + */ + val concludedLicense: SpdxExpression?, + + /** + * The licenses declared by the package. + */ + val declaredLicenses: List, + + /** + * The detected licenses aggregated from all [ScanResult]s for this package. + */ + val detectedLicenses: List, + + /** + * The effective license of the package derived from the licenses of the license sources chosen by a + * LicenseView, with optional choices applied. + */ + val effectiveLicense: SpdxExpression?, + + /** + * All analyzer issues related to this package. + */ + val analyzerIssues: List, + + /** + * All scan issues related to this package. + */ + val scanIssues: List + ) + } data class IssueTable( val type: Type, diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt index 9f3ecd0c61f17..8d3a19cdddb75 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt @@ -30,9 +30,9 @@ import org.ossreviewtoolkit.model.config.Excludes import org.ossreviewtoolkit.model.config.ScopeExclude import org.ossreviewtoolkit.model.licenses.LicenseView import org.ossreviewtoolkit.model.orEmpty -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.DependencyRow import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.IssueTable import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ProjectTable +import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ProjectTable.Row import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ResolvableIssue import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ResolvableViolation import org.ossreviewtoolkit.reporter.HowToFixTextProvider @@ -73,7 +73,7 @@ internal object ReportTableModelMapper { val pkg = input.ortResult.getPackageOrProject(id)?.metadata - DependencyRow( + Row( id = id, sourceArtifact = pkg?.sourceArtifact.orEmpty(), vcsInfo = pkg?.vcsProcessed.orEmpty(), diff --git a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt index 8a44ba56951ce..51e9186c613cc 100644 --- a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt +++ b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt @@ -457,7 +457,7 @@ class StaticHtmlReporter : Reporter { } } - private fun TBODY.projectRow(projectId: String, rowIndex: Int, row: ReportTable.DependencyRow) { + private fun TBODY.projectRow(projectId: String, rowIndex: Int, row: ProjectTable.Row) { // Only mark the row as excluded if all scopes the dependency appears in are excluded. val rowExcludedClass = if (row.scopes.isNotEmpty() && row.scopes.all { it.value.isNotEmpty() }) "ort-excluded" else "" From 885add72ce9eb8822f00b9a5a671937ecf8f14c9 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 2 May 2024 08:30:24 +0200 Subject: [PATCH 3/9] refactor(static-html): Use a shorter name for `IssueRow` Also move the class into `IssueTable` to allow for that shorter name. Signed-off-by: Frank Viernau --- .../src/main/kotlin/ReportTable.kt | 24 +++++++++---------- .../src/main/kotlin/ReportTableModelMapper.kt | 4 ++-- .../src/main/kotlin/StaticHtmlReporter.kt | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt index 7feb6df410226..ad8bf9859556e 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt @@ -153,7 +153,7 @@ internal data class ReportTable( data class IssueTable( val type: Type, - val rows: List + val rows: List ) { val errorCount = rows.count { it.issue.severity == Severity.ERROR } val warningCount = rows.count { it.issue.severity == Severity.WARNING } @@ -164,19 +164,19 @@ internal data class ReportTable( SCANNER, ADVISOR } - } - data class IssueRow( - /** - * All analyzer issues related to this package, grouped by the [Identifier] of the [Project] they appear in. - */ - val issue: ResolvableIssue, + data class Row( + /** + * All analyzer issues related to this package, grouped by the [Identifier] of the [Project] they appear in. + */ + val issue: ResolvableIssue, - /** - * The identifier of the package the issue corresponds to. - */ - val id: Identifier - ) + /** + * The identifier of the package the issue corresponds to. + */ + val id: Identifier + ) + } data class ResolvableIssue( val source: String, diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt index 8d3a19cdddb75..400ffb30adf7c 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt @@ -200,9 +200,9 @@ private fun Map>.toIssueSummaryTable(type: IssueTable.Typ val rows = flatMap { (id, issues) -> issues.map { issue -> val resolvableIssue = issue.toResolvableIssue(input.ortResult, input.howToFixTextProvider) - ReportTable.IssueRow(resolvableIssue, id) + IssueTable.Row(resolvableIssue, id) } - }.sortedWith(compareByDescending { it.issue.severity }.thenBy { it.id }) + }.sortedWith(compareByDescending { it.issue.severity }.thenBy { it.id }) return IssueTable(type, rows) } diff --git a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt index 51e9186c613cc..418067cb881d9 100644 --- a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt +++ b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt @@ -357,7 +357,7 @@ class StaticHtmlReporter : Reporter { } } - private fun TBODY.issueRow(rowId: String, rowIndex: Int, row: ReportTable.IssueRow) { + private fun TBODY.issueRow(rowId: String, rowIndex: Int, row: IssueTable.Row) { val cssClass = when (row.issue.severity) { Severity.ERROR -> "ort-error" Severity.WARNING -> "ort-warning" From e34b9918b70c0387031af5b9534fffaa610d317f Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 2 May 2024 08:37:54 +0200 Subject: [PATCH 4/9] refactor(static-html): Reduce nesting of model classes Move all direct nested class of `ReportTable` to the top level for a better overview. Signed-off-by: Frank Viernau --- .../src/main/kotlin/ReportTable.kt | 206 +++++++++--------- .../src/main/kotlin/ReportTableModelMapper.kt | 6 +- .../src/main/kotlin/StaticHtmlReporter.kt | 9 +- 3 files changed, 107 insertions(+), 114 deletions(-) diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt index ad8bf9859556e..8366864ad13ac 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt @@ -35,7 +35,7 @@ import org.ossreviewtoolkit.model.config.ScopeExclude import org.ossreviewtoolkit.model.licenses.ResolvedLicense import org.ossreviewtoolkit.utils.spdx.SpdxExpression -internal fun Collection.containsUnresolved() = any { !it.isResolved } +internal fun Collection.containsUnresolved() = any { !it.isResolved } internal data class ReportTable( /** @@ -77,119 +77,119 @@ internal data class ReportTable( * The labels from [OrtResult.labels]. */ val labels: Map +) + +internal data class IssueTable( + val type: Type, + val rows: List ) { - data class ProjectTable( + val errorCount = rows.count { it.issue.severity == Severity.ERROR } + val warningCount = rows.count { it.issue.severity == Severity.WARNING } + val hintCount = rows.count { it.issue.severity == Severity.HINT } + + enum class Type { + ANALYZER, + SCANNER, + ADVISOR + } + + data class Row( /** - * The dependencies of this project. + * All analyzer issues related to this package, grouped by the [Identifier] of the [Project] they appear in. */ - val rows: List, + val issue: ResolvableIssue, /** - * The path to the directory containing the definition file of the project, relative to the analyzer root, - * see [OrtResult.getDefinitionFilePathRelativeToAnalyzerRoot]. + * The identifier of the package the issue corresponds to. */ - val fullDefinitionFilePath: String, + val id: Identifier + ) +} + +internal data class ProjectTable( + /** + * The dependencies of this project. + */ + val rows: List, + + /** + * The path to the directory containing the definition file of the project, relative to the analyzer root, + * see [OrtResult.getDefinitionFilePathRelativeToAnalyzerRoot]. + */ + val fullDefinitionFilePath: String, + /** + * Information about if and why the project is excluded by [PathExclude]s. + */ + val pathExcludes: List +) { + fun isExcluded() = pathExcludes.isNotEmpty() + + data class Row( /** - * Information about if and why the project is excluded by [PathExclude]s. + * The identifier of the package. */ - val pathExcludes: List - ) { - fun isExcluded() = pathExcludes.isNotEmpty() - - data class Row( - /** - * The identifier of the package. - */ - val id: Identifier, - - /** - * The remote artifact where the source package can be downloaded. - */ - val sourceArtifact: RemoteArtifact, - - /** - * The VCS information of the package. - */ - val vcsInfo: VcsInfo, - - /** - * The scopes the package is used in. - */ - val scopes: SortedMap>, - - /** - * The concluded license of the package. - */ - val concludedLicense: SpdxExpression?, - - /** - * The licenses declared by the package. - */ - val declaredLicenses: List, - - /** - * The detected licenses aggregated from all [ScanResult]s for this package. - */ - val detectedLicenses: List, - - /** - * The effective license of the package derived from the licenses of the license sources chosen by a - * LicenseView, with optional choices applied. - */ - val effectiveLicense: SpdxExpression?, - - /** - * All analyzer issues related to this package. - */ - val analyzerIssues: List, - - /** - * All scan issues related to this package. - */ - val scanIssues: List - ) - } + val id: Identifier, - data class IssueTable( - val type: Type, - val rows: List - ) { - val errorCount = rows.count { it.issue.severity == Severity.ERROR } - val warningCount = rows.count { it.issue.severity == Severity.WARNING } - val hintCount = rows.count { it.issue.severity == Severity.HINT } - - enum class Type { - ANALYZER, - SCANNER, - ADVISOR - } - - data class Row( - /** - * All analyzer issues related to this package, grouped by the [Identifier] of the [Project] they appear in. - */ - val issue: ResolvableIssue, - - /** - * The identifier of the package the issue corresponds to. - */ - val id: Identifier - ) - } + /** + * The remote artifact where the source package can be downloaded. + */ + val sourceArtifact: RemoteArtifact, - data class ResolvableIssue( - val source: String, - val description: String, - val resolutionDescription: String, - val isResolved: Boolean, - val severity: Severity, - val howToFix: String - ) + /** + * The VCS information of the package. + */ + val vcsInfo: VcsInfo, - data class ResolvableViolation( - val violation: RuleViolation, - val resolutionDescription: String, - val isResolved: Boolean + /** + * The scopes the package is used in. + */ + val scopes: SortedMap>, + + /** + * The concluded license of the package. + */ + val concludedLicense: SpdxExpression?, + + /** + * The licenses declared by the package. + */ + val declaredLicenses: List, + + /** + * The detected licenses aggregated from all [ScanResult]s for this package. + */ + val detectedLicenses: List, + + /** + * The effective license of the package derived from the licenses of the license sources chosen by a + * LicenseView, with optional choices applied. + */ + val effectiveLicense: SpdxExpression?, + + /** + * All analyzer issues related to this package. + */ + val analyzerIssues: List, + + /** + * All scan issues related to this package. + */ + val scanIssues: List ) } + +internal data class ResolvableIssue( + val source: String, + val description: String, + val resolutionDescription: String, + val isResolved: Boolean, + val severity: Severity, + val howToFix: String +) + +internal data class ResolvableViolation( + val violation: RuleViolation, + val resolutionDescription: String, + val isResolved: Boolean +) diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt index 400ffb30adf7c..3805eb84063f6 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt @@ -30,11 +30,7 @@ import org.ossreviewtoolkit.model.config.Excludes import org.ossreviewtoolkit.model.config.ScopeExclude import org.ossreviewtoolkit.model.licenses.LicenseView import org.ossreviewtoolkit.model.orEmpty -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.IssueTable -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ProjectTable -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ProjectTable.Row -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ResolvableIssue -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ResolvableViolation +import org.ossreviewtoolkit.plugins.reporters.statichtml.ProjectTable.Row import org.ossreviewtoolkit.reporter.HowToFixTextProvider import org.ossreviewtoolkit.reporter.ReporterInput diff --git a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt index 418067cb881d9..6330d83f9cbec 100644 --- a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt +++ b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt @@ -47,9 +47,6 @@ import org.ossreviewtoolkit.model.config.RepositoryConfiguration import org.ossreviewtoolkit.model.config.ScopeExclude import org.ossreviewtoolkit.model.licenses.ResolvedLicenseLocation import org.ossreviewtoolkit.model.yamlMapper -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.IssueTable -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ProjectTable -import org.ossreviewtoolkit.plugins.reporters.statichtml.ReportTable.ResolvableIssue import org.ossreviewtoolkit.reporter.Reporter import org.ossreviewtoolkit.reporter.ReporterInput import org.ossreviewtoolkit.utils.common.isValidUri @@ -177,7 +174,7 @@ class StaticHtmlReporter : Reporter { return document.serialize().normalizeLineBreaks() } - private fun getRuleViolationSummaryString(ruleViolations: List): String { + private fun getRuleViolationSummaryString(ruleViolations: List): String { val violations = ruleViolations.filterNot { it.isResolved }.groupBy { it.violation.severity } val errorCount = violations[Severity.ERROR].orEmpty().size val warningCount = violations[Severity.WARNING].orEmpty().size @@ -259,7 +256,7 @@ class StaticHtmlReporter : Reporter { } } - private fun DIV.ruleViolationTable(ruleViolations: List) { + private fun DIV.ruleViolationTable(ruleViolations: List) { h2 { id = RULE_VIOLATION_TABLE_ID +getRuleViolationSummaryString(ruleViolations) @@ -288,7 +285,7 @@ class StaticHtmlReporter : Reporter { } } - private fun TBODY.ruleViolationRow(rowIndex: Int, ruleViolation: ReportTable.ResolvableViolation) { + private fun TBODY.ruleViolationRow(rowIndex: Int, ruleViolation: ResolvableViolation) { val cssClass = if (ruleViolation.isResolved) { "ort-resolved" } else { From 751ca868a12eb47765c1ce729071c4ba9cd8c602 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 2 May 2024 08:40:44 +0200 Subject: [PATCH 5/9] =?UTF-8?q?refactor(static-html):=20Move=20`containsUn?= =?UTF-8?q?resolved()=C2=B4=20out=20of=20the=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is only needed in the static HTML reporter. So, move it next to the other helper functions. Signed-off-by: Frank Viernau --- plugins/reporters/static-html/src/main/kotlin/ReportTable.kt | 2 -- .../reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt index 8366864ad13ac..75d5480309c8c 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt @@ -35,8 +35,6 @@ import org.ossreviewtoolkit.model.config.ScopeExclude import org.ossreviewtoolkit.model.licenses.ResolvedLicense import org.ossreviewtoolkit.utils.spdx.SpdxExpression -internal fun Collection.containsUnresolved() = any { !it.isResolved } - internal data class ReportTable( /** * The [VcsInfo] for the scanned project. diff --git a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt index 6330d83f9cbec..c47f723e73b43 100644 --- a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt +++ b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt @@ -723,3 +723,5 @@ private fun IssueTable.title(): String = private fun IssueTable.id(): String = "${type.name.lowercase()}-issue-summary" private fun IssueTable.rowId(index: Int): String = "${id()}-$index" + +private fun Collection.containsUnresolved() = any { !it.isResolved } From ec257ce0d459c1df26077edd874f6f096f04ae7b Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 2 May 2024 08:45:15 +0200 Subject: [PATCH 6/9] refactor(static-html): Rename the model and mapper to `TablesReport*` The report is table-based and consists of multiple tables. The previous name made it sound like it would be a single table. Signed-off-by: Frank Viernau --- .../src/main/kotlin/StaticHtmlReporter.kt | 56 +++++++++---------- .../{ReportTable.kt => TablesReport.kt} | 2 +- ...elMapper.kt => TablesReportModelMapper.kt} | 8 +-- 3 files changed, 33 insertions(+), 33 deletions(-) rename plugins/reporters/static-html/src/main/kotlin/{ReportTable.kt => TablesReport.kt} (99%) rename plugins/reporters/static-html/src/main/kotlin/{ReportTableModelMapper.kt => TablesReportModelMapper.kt} (97%) diff --git a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt index c47f723e73b43..38de1cd2ad107 100644 --- a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt +++ b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt @@ -72,9 +72,9 @@ class StaticHtmlReporter : Reporter { private val licensesSha1 = mutableMapOf() override fun generateReport(input: ReporterInput, outputDir: File, config: PluginConfiguration): List { - val reportTableModel = ReportTableModelMapper.map(input) + val tablesReport = TablesReportModelMapper.map(input) - val html = renderHtml(reportTableModel) + val html = renderHtml(tablesReport) val outputFile = outputDir.resolve(reportFilename) outputFile.bufferedWriter().use { @@ -84,7 +84,7 @@ class StaticHtmlReporter : Reporter { return listOf(outputFile) } - private fun renderHtml(reportTable: ReportTable): String { + private fun renderHtml(tablesReport: TablesReport): String { val document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument() document.append.html { @@ -135,38 +135,38 @@ class StaticHtmlReporter : Reporter { h2 { +"Project" } div { - with(reportTable.vcsInfo) { + with(tablesReport.vcsInfo) { +"Scanned revision $revision of $type repository $url" } } - if (reportTable.labels.isNotEmpty()) { - labelsTable(reportTable.labels) + if (tablesReport.labels.isNotEmpty()) { + labelsTable(tablesReport.labels) } - index(reportTable) + index(tablesReport) - reportTable.ruleViolations?.let { + tablesReport.ruleViolations?.let { ruleViolationTable(it) } - if (reportTable.analyzerIssueSummary.rows.isNotEmpty()) { - issueTable(reportTable.analyzerIssueSummary) + if (tablesReport.analyzerIssueSummary.rows.isNotEmpty()) { + issueTable(tablesReport.analyzerIssueSummary) } - if (reportTable.scannerIssueSummary.rows.isNotEmpty()) { - issueTable(reportTable.scannerIssueSummary) + if (tablesReport.scannerIssueSummary.rows.isNotEmpty()) { + issueTable(tablesReport.scannerIssueSummary) } - if (reportTable.advisorIssueSummary.rows.isNotEmpty()) { - issueTable(reportTable.advisorIssueSummary) + if (tablesReport.advisorIssueSummary.rows.isNotEmpty()) { + issueTable(tablesReport.advisorIssueSummary) } - reportTable.projectDependencies.forEach { (project, table) -> + tablesReport.projectDependencies.forEach { (project, table) -> projectTable(project, table) } - repositoryConfiguration(reportTable.config) + repositoryConfiguration(tablesReport.config) } } } @@ -197,11 +197,11 @@ class StaticHtmlReporter : Reporter { } } - private fun DIV.index(reportTable: ReportTable) { + private fun DIV.index(tablesReport: TablesReport) { h2 { +"Index" } ul { - reportTable.ruleViolations?.let { ruleViolations -> + tablesReport.ruleViolations?.let { ruleViolations -> li { a("#$RULE_VIOLATION_TABLE_ID") { +getRuleViolationSummaryString(ruleViolations) @@ -209,31 +209,31 @@ class StaticHtmlReporter : Reporter { } } - if (reportTable.analyzerIssueSummary.rows.isNotEmpty()) { + if (tablesReport.analyzerIssueSummary.rows.isNotEmpty()) { li { - a("#${reportTable.analyzerIssueSummary.id()}") { - +reportTable.analyzerIssueSummary.title() + a("#${tablesReport.analyzerIssueSummary.id()}") { + +tablesReport.analyzerIssueSummary.title() } } } - if (reportTable.scannerIssueSummary.rows.isNotEmpty()) { + if (tablesReport.scannerIssueSummary.rows.isNotEmpty()) { li { - a("#${reportTable.scannerIssueSummary.id()}") { - +reportTable.scannerIssueSummary.title() + a("#${tablesReport.scannerIssueSummary.id()}") { + +tablesReport.scannerIssueSummary.title() } } } - if (reportTable.advisorIssueSummary.rows.isNotEmpty()) { + if (tablesReport.advisorIssueSummary.rows.isNotEmpty()) { li { - a("#${reportTable.advisorIssueSummary.id()}") { - +reportTable.advisorIssueSummary.title() + a("#${tablesReport.advisorIssueSummary.id()}") { + +tablesReport.advisorIssueSummary.title() } } } - reportTable.projectDependencies.forEach { (project, projectTable) -> + tablesReport.projectDependencies.forEach { (project, projectTable) -> li { a("#${project.id.toCoordinates()}") { +project.id.toCoordinates() diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt b/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt similarity index 99% rename from plugins/reporters/static-html/src/main/kotlin/ReportTable.kt rename to plugins/reporters/static-html/src/main/kotlin/TablesReport.kt index 75d5480309c8c..85288a2eb009d 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTable.kt +++ b/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt @@ -35,7 +35,7 @@ import org.ossreviewtoolkit.model.config.ScopeExclude import org.ossreviewtoolkit.model.licenses.ResolvedLicense import org.ossreviewtoolkit.utils.spdx.SpdxExpression -internal data class ReportTable( +internal data class TablesReport( /** * The [VcsInfo] for the scanned project. */ diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt b/plugins/reporters/static-html/src/main/kotlin/TablesReportModelMapper.kt similarity index 97% rename from plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt rename to plugins/reporters/static-html/src/main/kotlin/TablesReportModelMapper.kt index 3805eb84063f6..05c56b2426c6c 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt +++ b/plugins/reporters/static-html/src/main/kotlin/TablesReportModelMapper.kt @@ -35,10 +35,10 @@ import org.ossreviewtoolkit.reporter.HowToFixTextProvider import org.ossreviewtoolkit.reporter.ReporterInput /** - * A mapper which converts an [OrtResult] to a [ReportTable]. + * A mapper which converts an [OrtResult] to a [TablesReport]. */ -internal object ReportTableModelMapper { - fun map(input: ReporterInput): ReportTable { +internal object TablesReportModelMapper { + fun map(input: ReporterInput): TablesReport { val analyzerResult = input.ortResult.analyzer?.result val excludes = input.ortResult.getExcludes() @@ -106,7 +106,7 @@ internal object ReportTableModelMapper { .map { it.toResolvableViolation(input.ortResult) } .sortedWith(VIOLATION_COMPARATOR) - return ReportTable( + return TablesReport( input.ortResult.repository.vcsProcessed, input.ortResult.repository.config, ruleViolations, From 92f2b014422c22ddac52a3958ec589744ee6eed8 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 2 May 2024 08:49:31 +0200 Subject: [PATCH 7/9] refactor(static-html): Use better names for issues and violations `ResolvableIssue` and `ResolvableRuleViolation` are the representations of issues and rule violations within the domain of the static HTML report model. So, use the name of the model as the prefix, instead of the "Resolvable" prefix which focuses too much on only one of its properties. Signed-off-by: Frank Viernau --- .../src/main/kotlin/StaticHtmlReporter.kt | 12 +++++------ .../src/main/kotlin/TablesReport.kt | 12 +++++------ .../main/kotlin/TablesReportModelMapper.kt | 21 +++++++++++-------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt index 38de1cd2ad107..fba2cc8eb6a47 100644 --- a/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt +++ b/plugins/reporters/static-html/src/main/kotlin/StaticHtmlReporter.kt @@ -174,7 +174,7 @@ class StaticHtmlReporter : Reporter { return document.serialize().normalizeLineBreaks() } - private fun getRuleViolationSummaryString(ruleViolations: List): String { + private fun getRuleViolationSummaryString(ruleViolations: List): String { val violations = ruleViolations.filterNot { it.isResolved }.groupBy { it.violation.severity } val errorCount = violations[Severity.ERROR].orEmpty().size val warningCount = violations[Severity.WARNING].orEmpty().size @@ -256,7 +256,7 @@ class StaticHtmlReporter : Reporter { } } - private fun DIV.ruleViolationTable(ruleViolations: List) { + private fun DIV.ruleViolationTable(ruleViolations: List) { h2 { id = RULE_VIOLATION_TABLE_ID +getRuleViolationSummaryString(ruleViolations) @@ -285,7 +285,7 @@ class StaticHtmlReporter : Reporter { } } - private fun TBODY.ruleViolationRow(rowIndex: Int, ruleViolation: ResolvableViolation) { + private fun TBODY.ruleViolationRow(rowIndex: Int, ruleViolation: TablesReportViolation) { val cssClass = if (ruleViolation.isResolved) { "ort-resolved" } else { @@ -565,7 +565,7 @@ class StaticHtmlReporter : Reporter { } } - private fun TD.issueList(issues: List) { + private fun TD.issueList(issues: List) { ul { issues.forEach { li { @@ -580,7 +580,7 @@ class StaticHtmlReporter : Reporter { } } - private fun P.issueDescription(issue: ResolvableIssue) { + private fun P.issueDescription(issue: TablesReportIssue) { var first = true issue.description.lines().forEach { if (first) first = false else br @@ -724,4 +724,4 @@ private fun IssueTable.id(): String = "${type.name.lowercase()}-issue-summary" private fun IssueTable.rowId(index: Int): String = "${id()}-$index" -private fun Collection.containsUnresolved() = any { !it.isResolved } +private fun Collection.containsUnresolved() = any { !it.isResolved } diff --git a/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt b/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt index 85288a2eb009d..ee32fb99a71e8 100644 --- a/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt +++ b/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt @@ -49,7 +49,7 @@ internal data class TablesReport( /** * A list containing all evaluator rule violations. `null` if no evaluator result is available. */ - val ruleViolations: List?, + val ruleViolations: List?, /** * An [IssueTable] containing all dependencies that caused issues. @@ -95,7 +95,7 @@ internal data class IssueTable( /** * All analyzer issues related to this package, grouped by the [Identifier] of the [Project] they appear in. */ - val issue: ResolvableIssue, + val issue: TablesReportIssue, /** * The identifier of the package the issue corresponds to. @@ -168,16 +168,16 @@ internal data class ProjectTable( /** * All analyzer issues related to this package. */ - val analyzerIssues: List, + val analyzerIssues: List, /** * All scan issues related to this package. */ - val scanIssues: List + val scanIssues: List ) } -internal data class ResolvableIssue( +internal data class TablesReportIssue( val source: String, val description: String, val resolutionDescription: String, @@ -186,7 +186,7 @@ internal data class ResolvableIssue( val howToFix: String ) -internal data class ResolvableViolation( +internal data class TablesReportViolation( val violation: RuleViolation, val resolutionDescription: String, val isResolved: Boolean diff --git a/plugins/reporters/static-html/src/main/kotlin/TablesReportModelMapper.kt b/plugins/reporters/static-html/src/main/kotlin/TablesReportModelMapper.kt index 05c56b2426c6c..df46d438a6de7 100644 --- a/plugins/reporters/static-html/src/main/kotlin/TablesReportModelMapper.kt +++ b/plugins/reporters/static-html/src/main/kotlin/TablesReportModelMapper.kt @@ -83,10 +83,10 @@ internal object TablesReportModelMapper { input.ortResult.getRepositoryLicenseChoices() )?.sorted(), analyzerIssues = analyzerIssues.map { - it.toResolvableIssue(input.ortResult, input.howToFixTextProvider) + it.toTableReportIssue(input.ortResult, input.howToFixTextProvider) }, scanIssues = scanIssues.map { - it.toResolvableIssue(input.ortResult, input.howToFixTextProvider) + it.toTableReportIssue(input.ortResult, input.howToFixTextProvider) } ) } @@ -103,7 +103,7 @@ internal object TablesReportModelMapper { val labels = input.ortResult.labels.mapKeys { it.key.substringAfter(".") } val ruleViolations = input.ortResult.getRuleViolations() - .map { it.toResolvableViolation(input.ortResult) } + .map { it.toTableReportViolation(input.ortResult) } .sortedWith(VIOLATION_COMPARATOR) return TablesReport( @@ -119,7 +119,7 @@ internal object TablesReportModelMapper { } } -private val VIOLATION_COMPARATOR = compareBy { it.isResolved } +private val VIOLATION_COMPARATOR = compareBy { it.isResolved } .thenByDescending { it.violation.severity } .thenBy { it.violation.rule } .thenBy { it.violation.pkg } @@ -143,9 +143,12 @@ private fun Project.getScopesForDependencies( return result } -private fun Issue.toResolvableIssue(ortResult: OrtResult, howToFixTextProvider: HowToFixTextProvider): ResolvableIssue { +private fun Issue.toTableReportIssue( + ortResult: OrtResult, + howToFixTextProvider: HowToFixTextProvider +): TablesReportIssue { val resolutions = ortResult.getResolutionsFor(this) - return ResolvableIssue( + return TablesReportIssue( source = source, description = toString(), resolutionDescription = buildString { @@ -163,9 +166,9 @@ private fun Issue.toResolvableIssue(ortResult: OrtResult, howToFixTextProvider: ) } -private fun RuleViolation.toResolvableViolation(ortResult: OrtResult): ResolvableViolation { +private fun RuleViolation.toTableReportViolation(ortResult: OrtResult): TablesReportViolation { val resolutions = ortResult.getResolutionsFor(this) - return ResolvableViolation( + return TablesReportViolation( violation = this, resolutionDescription = buildString { if (resolutions.isNotEmpty()) { @@ -195,7 +198,7 @@ private fun getAdvisorIssueSummaryTable(input: ReporterInput): IssueTable = private fun Map>.toIssueSummaryTable(type: IssueTable.Type, input: ReporterInput): IssueTable { val rows = flatMap { (id, issues) -> issues.map { issue -> - val resolvableIssue = issue.toResolvableIssue(input.ortResult, input.howToFixTextProvider) + val resolvableIssue = issue.toTableReportIssue(input.ortResult, input.howToFixTextProvider) IssueTable.Row(resolvableIssue, id) } }.sortedWith(compareByDescending { it.issue.severity }.thenBy { it.id }) From 377979100074ed5ba96ab0565cb2adfc6d3d5850 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 2 May 2024 08:58:49 +0200 Subject: [PATCH 8/9] docs(static-html): Re-align the KDocs for the summary tables This is a fix-up of 237f3e2 and 9c6b867. Signed-off-by: Frank Viernau --- .../reporters/static-html/src/main/kotlin/TablesReport.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt b/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt index ee32fb99a71e8..1dfbe7d063f42 100644 --- a/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt +++ b/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt @@ -52,17 +52,17 @@ internal data class TablesReport( val ruleViolations: List?, /** - * An [IssueTable] containing all dependencies that caused issues. + * An [IssueTable] containing all analyzer issues. */ val analyzerIssueSummary: IssueTable, /** - * A [IssueTable] containing all scanner issues. + * An [IssueTable] containing all scanner issues. */ val scannerIssueSummary: IssueTable, /** - * A [IssueTable] containing all advisor issues. + * An [IssueTable] containing all advisor issues. */ val advisorIssueSummary: IssueTable, From 704a86f49b6820e06a0892632abb9704cfbdc5d9 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 2 May 2024 09:02:31 +0200 Subject: [PATCH 9/9] docs(static-html): Fix-up the KDoc for `Row.issue` This is a fix-up for 9c6b867. Signed-off-by: Frank Viernau --- plugins/reporters/static-html/src/main/kotlin/TablesReport.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt b/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt index 1dfbe7d063f42..c16def7615512 100644 --- a/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt +++ b/plugins/reporters/static-html/src/main/kotlin/TablesReport.kt @@ -93,7 +93,7 @@ internal data class IssueTable( data class Row( /** - * All analyzer issues related to this package, grouped by the [Identifier] of the [Project] they appear in. + * The issue of this row represents of the given [type][type]. */ val issue: TablesReportIssue,