Skip to content

Commit

Permalink
refactor(static-html): Factor out Scope.isExcluded()
Browse files Browse the repository at this point in the history
Improve the readability in the caller. While at it, simplify the caller
a bit.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed May 15, 2024
1 parent 01fefea commit defc141
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class StaticHtmlReporter : Reporter {
if (row.scopes.isNotEmpty()) {
ul {
row.scopes.forEach { scope ->
val excludedClass = if (scope.excludes.isNotEmpty()) "excluded" else ""
val excludedClass = "excluded".takeIf { scope.isExcluded() }.orEmpty()
li(excludedClass) {
+scope.name
if (scope.excludes.isNotEmpty()) {
Expand Down
9 changes: 7 additions & 2 deletions plugins/reporters/static-html/src/main/kotlin/TablesReport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ internal data class ProjectTable(
/**
* Return true if and only if this [Row] is excluded by any [ScopeExclude]s
*/
fun isExcluded(): Boolean = scopes.isNotEmpty() && scopes.all { it.excludes.isNotEmpty() }
fun isExcluded(): Boolean = scopes.isNotEmpty() && scopes.all { it.isExcluded() }
}

data class Scope(
Expand All @@ -199,7 +199,12 @@ internal data class ProjectTable(
* The excludes matching this scope.
*/
val excludes: List<ScopeExclude>
)
) {
/**
* Return true if an only if this scope is matched by any [ScopeExclude]'s.
*/
fun isExcluded(): Boolean = excludes.isNotEmpty()
}
}

internal data class TablesReportIssue(
Expand Down

0 comments on commit defc141

Please sign in to comment.