Skip to content

Commit

Permalink
Merge pull request #573 from yschimke/output_error
Browse files Browse the repository at this point in the history
Apply suppressions to AccessibilityViewCheckResult instead of filtering
  • Loading branch information
takahirom authored Nov 23, 2024
2 parents 5f3586c + 09cdd39 commit a26abf4
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,24 @@ data class RoborazziATFAccessibilityChecker(

val results = viewChecker.runChecksOnView(ImmutableSet.copyOf(checks), view, parameters)

return results.filter {
!suppressions.matches(it)
return results.applySuppressions(suppressions)
}

private fun List<AccessibilityViewCheckResult>.applySuppressions(
suppressions: Matcher<in AccessibilityViewCheckResult>
): List<AccessibilityViewCheckResult> {
val ranTypes = listOf(
AccessibilityCheckResultType.ERROR,
AccessibilityCheckResultType.WARNING,
AccessibilityCheckResultType.INFO
)

return map { checkResult ->
if (suppressions.matches(checkResult) && ranTypes.contains(checkResult.type)) {
checkResult.suppressedResultCopy
} else {
checkResult
}
}
}

Expand All @@ -210,6 +226,9 @@ data class RoborazziATFAccessibilityChecker(
AccessibilityCheckResultType.WARNING -> roborazziErrorLog(
"Warning: $check"
)
AccessibilityCheckResultType.SUPPRESSED -> roborazziReportLog(
"Suppressed: $check"
)

AccessibilityCheckResultType.INFO -> roborazziReportLog(
"Info: $check"
Expand Down

0 comments on commit a26abf4

Please sign in to comment.