Skip to content

Commit

Permalink
refactor(static-html): Pass the project table to projectRow()
Browse files Browse the repository at this point in the history
This removes the need to pass the project ID separately, and also
simplifies an upcoming change.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed May 15, 2024
1 parent ddd4497 commit a47efba
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,17 @@ class StaticHtmlReporter : Reporter {
}

tbody {
table.rows.forEachIndexed { rowIndex, row ->
projectRow(table.id.toCoordinates(), rowIndex + 1, row)
repeat(table.rows.size) { index ->
projectRow(table, index)
}
}
}
}

private fun TBODY.projectRow(projectId: String, rowIndex: Int, row: ProjectTable.Row) {
private fun TBODY.projectRow(projectTable: ProjectTable, rowIndex: Int) {
val row = projectTable.rows[rowIndex]
val rowId = "${projectTable.id.toCoordinates()}-pkg-${rowIndex + 1}"

// 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.excludes.isNotEmpty() }) "excluded" else ""
Expand All @@ -463,14 +466,12 @@ class StaticHtmlReporter : Reporter {
else -> "success"
}

val rowId = "$projectId-pkg-$rowIndex"

tr("$cssClass $rowExcludedClass") {
id = rowId
td {
a {
href = "#$rowId"
+rowIndex.toString()
+(rowIndex + 1).toString()
}
}
td { +row.id.toCoordinates() }
Expand Down

0 comments on commit a47efba

Please sign in to comment.