Skip to content

Commit

Permalink
fix(commands): Avoid a duplicate plural "s" in the summary sentence
Browse files Browse the repository at this point in the history
This fixes the "ss" in a sentence like "There are 138 unresolved rule
violationss with a severity ...".

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Dec 5, 2023
1 parent bec02fd commit ba66567
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ class SeverityStatsPrinter(private val terminal: Terminal, private val resolutio
Theme.Default.success(text)
}

terminal.println("${Theme.Default.info("Resolved $name:")} ${resolved.joinToString()}.")
terminal.println("${Theme.Default.info("Resolved ${name}s:")} ${resolved.joinToString()}.")

val unresolved = Severity.entries.toTypedArray().sortedArrayDescending().map {
val count = unresolvedCounts.getOrDefault(it, 0)
val text = p(count, it.name.lowercase())
if (count == 0) Theme.Default.success(text) else Theme.Default.danger(text)
}

terminal.println("${Theme.Default.warning("Unresolved $name:")} ${unresolved.joinToString()}.")
terminal.println("${Theme.Default.warning("Unresolved ${name}s:")} ${unresolved.joinToString()}.")
}

/**
Expand Down Expand Up @@ -86,11 +86,11 @@ class SeverityStatsPrinter(private val terminal: Terminal, private val resolutio

@JvmName("statsForIssues")
fun stats(issues: Collection<Issue>) =
stats("issues", issues.partition { resolutionProvider.isResolved(it) }) { severity }
stats("issue", issues.partition { resolutionProvider.isResolved(it) }) { severity }

@JvmName("statsForRuleViolations")
fun stats(ruleViolations: Collection<RuleViolation>) =
stats("rule violations", ruleViolations.partition { resolutionProvider.isResolved(it) }) { severity }
stats("rule violation", ruleViolations.partition { resolutionProvider.isResolved(it) }) { severity }

private fun <T> stats(name: String, thingsWithSeverities: Pair<List<T>, List<T>>, selector: T.() -> Severity) =
Entry(
Expand Down

0 comments on commit ba66567

Please sign in to comment.