This repository has been archived on 2023-10-10. You can view files and clone it, but cannot push or open issues or pull requests.
DroneHelper/src/Reports/Format-FileLinterReport.ps1

44 lines
1.2 KiB
PowerShell
Raw Normal View History

2022-07-13 13:59:25 +02:00
function Format-FileLinterReport {
<#
.SYNOPSIS
Private helper function used by Write-ResultFile.
#>
[CmdletBinding()]
[OutputType([string])]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[PSTypeName('DroneHelper.FileLinter.Report')]$InputObject
)
begin {
}
process {
$Output = @()
if ($InputObject.Success) {
$Output += ':heavy_check_mark: No FileLinter violations in {0} files found.' -f $InputObject.FilesCount
}
else {
$Output += "| Result | File | Failed |"
$Output += "| :----: | :--- | -----: |"
foreach ($file in $InputObject.Files) {
if ($file.FailedCount -gt 0) {
$failedTestNames = (
$file.Tests.GetEnumerator() | Where-Object {
$_.Value -eq $false
} | Select-Object -ExpandProperty 'Name'
) -join ', '
$Output += "| :heavy_exclamation_mark: | ``{0}`` | ``{1}`` |" -f $file.Name, $failedTestNames
}
}
}
Write-Output $Output
}
end {
}
}