Open
Description
Steps to reproduce
Run Invoke-ScriptAnalyzer
against the following with the new 1.19.0 release.
function foo {
Param(
$MyParameter
)
Get-Item| ForEach-Object { Get-ChildItem $MyParameter }
}
Expected behavior
No rule violations.
Actual behavior
The new ReviewUnusedParameter
rule doesn't notice the usage. I suspect this is similar to the limitation of the AvoidUsingCmdletAliases
rule though. Not sure if we should relax the ReviewUnusedParameter
rule in this case to search nested scriptblocks inside a function scope.
cc @mattmcnabb @rjmholt @JamesWTruher
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSReviewUnusedParameter Warning test.ps1 4 The parameter 'MyParameter' has been declared but not used.
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 7.1.0-preview.2
PSEdition Core
GitCommitId 7.1.0-preview.2
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0
Activity