41 lines
1.2 KiB
PowerShell
41 lines
1.2 KiB
PowerShell
|
function Format-ScriptAnalyzerReport {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Private helper function used by Write-ResultFile.
|
||
|
#>
|
||
|
|
||
|
[CmdletBinding()]
|
||
|
[OutputType([string])]
|
||
|
|
||
|
param (
|
||
|
[Parameter(Mandatory = $true)]
|
||
|
[PSCustomObject]$InputObject
|
||
|
)
|
||
|
|
||
|
begin {
|
||
|
}
|
||
|
|
||
|
process {
|
||
|
$Output = @()
|
||
|
$Output += "| Severity | ScriptName | Line | RuleName | Message |"
|
||
|
$Output += "| :------: | :--------- | :--: | :------- | :------ |"
|
||
|
|
||
|
foreach ( $v in $InputObject ) {
|
||
|
switch ($v.Severity) {
|
||
|
'Warning' { $Emoji = ':warning:' }
|
||
|
'Error' { $Emoji = ':heavy_exclamation_mark:' }
|
||
|
'Information' { $Emoji = ':mag:' }
|
||
|
Default { $Emoji = ':fried_egg:' }
|
||
|
}
|
||
|
$RawString = "| {0} | {1} | {2} | {3} | {4} |"
|
||
|
$Output += $RawString -f $Emoji, $v.ScriptName, $v.Line, $v.RuleName, $v.Message
|
||
|
}
|
||
|
$RuleURL = 'https://github.com/PowerShell/PSScriptAnalyzer/tree/master/RuleDocumentation'
|
||
|
$Output += "`n> See [RuleDocumentation]({0}) for additional help.`n" -f $RuleURL
|
||
|
Write-Output $Output
|
||
|
}
|
||
|
|
||
|
end {
|
||
|
}
|
||
|
}
|