Skip to content

Commit

Permalink
refactor(static-html): Make the ProjectTable self-contained
Browse files Browse the repository at this point in the history
Put all needed information into the project table, so that it is no more
necessary to pass the project as a separate argument.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed May 7, 2024
1 parent e547afa commit e8360e6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import org.ossreviewtoolkit.model.ArtifactProvenance
import org.ossreviewtoolkit.model.HashAlgorithm
import org.ossreviewtoolkit.model.Identifier
import org.ossreviewtoolkit.model.PackageProvider
import org.ossreviewtoolkit.model.Project
import org.ossreviewtoolkit.model.Provenance
import org.ossreviewtoolkit.model.RemoteArtifact
import org.ossreviewtoolkit.model.RepositoryProvenance
Expand Down Expand Up @@ -162,8 +161,8 @@ class StaticHtmlReporter : Reporter {
issueTable(tablesReport.advisorIssueSummary)
}

tablesReport.projectDependencies.forEach { (project, table) ->
projectTable(project, table)
tablesReport.projectDependencies.forEach { (_, table) ->
projectTable(table)
}

repositoryConfiguration(tablesReport.config)
Expand Down Expand Up @@ -386,12 +385,12 @@ class StaticHtmlReporter : Reporter {
}
}

private fun DIV.projectTable(project: Project, table: ProjectTable) {
private fun DIV.projectTable(table: ProjectTable) {
val excludedClass = "ort-excluded".takeIf { table.isExcluded() }.orEmpty()

h2 {
id = project.id.toCoordinates()
+"${project.id.toCoordinates()} (${table.fullDefinitionFilePath})"
id = table.id.toCoordinates()
+"${table.id.toCoordinates()} (${table.fullDefinitionFilePath})"
}

if (table.isExcluded()) {
Expand All @@ -405,7 +404,7 @@ class StaticHtmlReporter : Reporter {
}
}

project.vcsProcessed.let { vcsInfo ->
table.vcs.let { vcsInfo ->
h3(excludedClass) { +"VCS Information" }

table("ort-report-labels $excludedClass") {
Expand Down Expand Up @@ -446,7 +445,7 @@ class StaticHtmlReporter : Reporter {

tbody {
table.rows.forEachIndexed { rowIndex, row ->
projectRow(project.id.toCoordinates(), rowIndex + 1, row)
projectRow(table.id.toCoordinates(), rowIndex + 1, row)
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions plugins/reporters/static-html/src/main/kotlin/TablesReport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ internal data class IssueTable(
}

internal data class ProjectTable(
/**
* The identifier of the project.
*/
val id: Identifier,

/**
* The (processed) VCS info of the project.
*/
val vcs: VcsInfo,

/**
* The dependencies of this project.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ private fun getProjectTable(input: ReporterInput, project: Project): ProjectTabl
}

return ProjectTable(
id = project.id,
vcs = project.vcsProcessed,
rows = rows.sortedWith(compareByDescending<Row> { it.id == project.id }.thenBy { it.id }),
fullDefinitionFilePath = input.ortResult.getDefinitionFilePathRelativeToAnalyzerRoot(project),
pathExcludes = input.ortResult.getExcludes().findPathExcludes(project, input.ortResult)
Expand Down

0 comments on commit e8360e6

Please sign in to comment.