Skip to content

Commit

Permalink
chore(reporter)!: Remove the unused SummaryTable
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Nov 23, 2023
1 parent bd2d37d commit eb0e6f1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 94 deletions.
61 changes: 0 additions & 61 deletions reporter/src/main/kotlin/ReportTableModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.ossreviewtoolkit.reporter

import java.util.SortedMap
import java.util.SortedSet

import org.ossreviewtoolkit.model.Identifier
import org.ossreviewtoolkit.model.OrtResult
Expand All @@ -35,7 +34,6 @@ import org.ossreviewtoolkit.model.config.RepositoryConfiguration
import org.ossreviewtoolkit.model.config.ScopeExclude
import org.ossreviewtoolkit.model.licenses.ResolvedLicense
import org.ossreviewtoolkit.utils.common.zipWithCollections
import org.ossreviewtoolkit.utils.common.zipWithDefault
import org.ossreviewtoolkit.utils.spdx.SpdxExpression

fun Collection<ReportTableModel.ResolvableIssue>.containsUnresolved() = any { !it.isResolved }
Expand All @@ -61,11 +59,6 @@ data class ReportTableModel(
*/
val issueSummary: IssueTable,

/**
* A [SummaryTable] containing the dependencies of all [Project]s.
*/
val summary: SummaryTable,

/**
* The [ProjectTable]s containing the dependencies for each [Project].
*/
Expand Down Expand Up @@ -149,60 +142,6 @@ data class ReportTableModel(
val scanIssues: List<ResolvableIssue>
)

data class SummaryTable(
val rows: List<SummaryRow>
)

data class SummaryRow(
/**
* The identifier of the package.
*/
val id: Identifier,

/**
* The scopes the package is used in, grouped by the [Identifier] of the [Project] they appear in.
*/
val scopes: SortedMap<Identifier, SortedMap<String, List<ScopeExclude>>>,

/**
* The concluded licenses of the package.
*/
val concludedLicenses: Set<SpdxExpression>,

/**
* The licenses declared by the package.
*/
val declaredLicenses: Set<String>,

/**
* The detected licenses aggregated from all [ScanResult]s for this package.
*/
val detectedLicenses: SortedSet<String>,

/**
* All analyzer issues related to this package, grouped by the [Identifier] of the [Project] they appear in.
*/
val analyzerIssues: SortedMap<Identifier, List<ResolvableIssue>>,

/**
* All scan issues related to this package, grouped by the [Identifier] of the [Project] they appear in.
*/
val scanIssues: SortedMap<Identifier, List<ResolvableIssue>>
) {
fun merge(other: SummaryRow) =
SummaryRow(
id = id,
scopes = scopes.zipWithDefault(other.scopes, sortedMapOf()) { left, right ->
left.zipWithCollections(right).toSortedMap()
}.toSortedMap(),
concludedLicenses = concludedLicenses + other.concludedLicenses,
declaredLicenses = declaredLicenses + other.declaredLicenses,
detectedLicenses = (detectedLicenses + other.detectedLicenses).toSortedSet(),
analyzerIssues = analyzerIssues.zipWithCollections(other.analyzerIssues).toSortedMap(),
scanIssues = scanIssues.zipWithCollections(other.scanIssues).toSortedMap()
)
}

data class IssueTable(
val rows: List<IssueRow>
) {
Expand Down
33 changes: 0 additions & 33 deletions reporter/src/main/kotlin/ReportTableModelMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import org.ossreviewtoolkit.reporter.ReportTableModel.IssueTable
import org.ossreviewtoolkit.reporter.ReportTableModel.ProjectTable
import org.ossreviewtoolkit.reporter.ReportTableModel.ResolvableIssue
import org.ossreviewtoolkit.reporter.ReportTableModel.ResolvableViolation
import org.ossreviewtoolkit.reporter.ReportTableModel.SummaryRow
import org.ossreviewtoolkit.reporter.ReportTableModel.SummaryTable

/**
* A mapper which converts an [OrtResult] to a [ReportTableModel].
Expand All @@ -52,7 +50,6 @@ object ReportTableModelMapper {
howToFixTextProvider: HowToFixTextProvider
): ReportTableModel {
val issueSummaryRows = mutableMapOf<Identifier, IssueRow>()
val summaryRows = mutableMapOf<Identifier, SummaryRow>()

val analyzerResult = ortResult.analyzer?.result
val excludes = ortResult.getExcludes()
Expand Down Expand Up @@ -104,30 +101,6 @@ object ReportTableModelMapper {
)

val isRowExcluded = ortResult.isExcluded(row.id)

val nonExcludedAnalyzerIssues = if (isRowExcluded) emptyList() else row.analyzerIssues
val nonExcludedScanIssues = if (isRowExcluded) emptyList() else row.scanIssues

val summaryRow = SummaryRow(
id = row.id,
scopes = sortedMapOf(project.id to row.scopes),
concludedLicenses = row.concludedLicense?.let { setOf(it) }.orEmpty(),
declaredLicenses = row.declaredLicenses.mapTo(mutableSetOf()) { it.license.toString() },
detectedLicenses = row.detectedLicenses.mapTo(sortedSetOf()) { it.license.toString() },
analyzerIssues = if (nonExcludedAnalyzerIssues.isNotEmpty()) {
sortedMapOf(project.id to nonExcludedAnalyzerIssues)
} else {
sortedMapOf()
},
scanIssues = if (nonExcludedScanIssues.isNotEmpty()) {
sortedMapOf(project.id to nonExcludedScanIssues)
} else {
sortedMapOf()
}
)

summaryRows[row.id] = summaryRows[row.id]?.merge(summaryRow) ?: summaryRow

val unresolvedAnalyzerIssues = row.analyzerIssues.filterUnresolved()
val unresolvedScanIssues = row.scanIssues.filterUnresolved()

Expand Down Expand Up @@ -163,11 +136,6 @@ object ReportTableModelMapper {

val issueSummaryTable = IssueTable(issueSummaryRows.values.sortedBy { it.id })

val summaryTable = SummaryTable(
// Sort excluded rows to the end of the list.
summaryRows.values.sortedWith(compareBy({ ortResult.isExcluded(it.id) }, { it.id }))
)

// TODO: Use the prefixes up until the first '.' (which below get discarded) for some visual grouping in the
// report.
val labels = ortResult.labels.mapKeys { it.key.substringAfter(".") }
Expand All @@ -181,7 +149,6 @@ object ReportTableModelMapper {
ortResult.repository.config,
ruleViolations,
issueSummaryTable,
summaryTable,
projectTables,
labels
)
Expand Down

0 comments on commit eb0e6f1

Please sign in to comment.