Closed
Description
Steps to reproduce
Now I suppressed one rule twice in “function start-bar”.
- PowerShell script: build.ps1
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope='Function', Target='start-ba[rz]',Justification="aa")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope='Function', Target='start-bar',Justification="bb")]
param()
function start-foo {
write-host "start-foo"
}
function start-bar {
write-host "start-bar"
}
function start-bam {
write-host "start-bam"
}
- if you already import the module, may skip this step.
Import-Module .\out\PSScriptAnalyzer\1.20.0\PSScriptAnalyzer.psd1
- run PSScriptAnalyzer to analyze build.ps1. If not add -SuppressedOnly parameter, it only outputs non-suppressed results. So I add -SuppressedOnly parameter to see suppressed results.
Invoke-ScriptAnalyzer D:\build.ps1 -Recurse -SuppressedOnly
Expected behavior
RuleName Severity ScriptName Line Justification
-------- -------- ---------- ---- -------------
PSAvoidUsingWriteHost Warning build.ps1 9 aa;bb
If one rule suppressed twice in the same line, it needs to have a list of suppressions for the diagnostic.
Actual behavior
RuleName Severity ScriptName Line Justification
-------- -------- ---------- ---- -------------
PSAvoidUsingWriteHost Warning build.ps1 9 aa
PSAvoidUsingWriteHost Warning build.ps1 9 bb
The results seem like the existing implementation generates an output for each suppression, rather than each diagnostic.
So it's maybe better to have a list of suppressions for each diagnostic.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.1023
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1023
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1