Closed
Description
Steps to reproduce
There may be some rare cases where we would be using ParameterSetName instead of ParameterName, for example
$sb = {
function Test-PSReviewUnusedParameter {
<#
#>
[CmdletBinding()]
Param(
[Parameter(ParameterSetName = 'Foo')]
[switch]
$FooBar
)
try{
if ($PSCmdlet.ParameterSetName -eq 'Foo') {
# I am doing something
}
} catch {
throw
}
}
}
# Invoke-ScriptAnalyzer -ScriptDefinition [scriptblock]$sb
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSReviewUnusedParameter Warning 9 The parameter 'FooBar' has been declared but not used.
Expected behavior
I expect this to be not flagged
Actual behavior
Flags it as violation
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0