-
-
Notifications
You must be signed in to change notification settings - Fork 475
Closed
Description
1. General summary of the issue
I have a function that declares a parameter. Even if it's is used in the function body, Pester says it's unused (PSReviewUnusedParameter
warning).
2. Describe Your Environment
Pester version : 4.10.1
PowerShell version : 5.1.17763.1007
OS version : Windows Server 2019 Datacenter
3. Expected Behavior
Consider this code (extracted from a more complex file:
function Install-Php() {
[OutputType()]
param (
[Parameter(Mandatory = $true, Position = 2, HelpMessage = 'Install a Thread-Safe version?')]
[bool] $ThreadSafe
)
process {
$searchReleaseStates = @()
$versionToInstall = $null
foreach ($searchReleaseState in $searchReleaseStates) {
$compatibleVersions = Get-PhpAvailableVersion -State $searchReleaseState | Where-Object { $_.FullVersion -match '...' -and $_.Architecture -eq '...' -and $_.ThreadSafe -eq $ThreadSafe }
}
}
end {
}
}
Pester should not mark the $ThreadSafe
parameter as unised.
4.Current Behavior
Pester raises a PSReviewUnusedParameter
warning.
RuleName | Severity | ScriptName | Line | Message |
---|---|---|---|---|
PSReviewUnusedParameter | Warning | Install-Php.ps1 | 58 | The parameter 'ThreadSafe' has been declared but not used. |
(see here)
Metadata
Metadata
Assignees
Labels
No labels