PSReviewUnusedParameter false positive for ValueFromPipeline by liamjpeters · Pull Request #2072 · PowerShell/PSScriptAnalyzer
PR Summary
Whether good practice or not, a parameter defined with ValueFromPipeline is flagged as unused when referred to by $_ or $PSItem within the process block of a function.
This PR checks for ValueFromPipeline when the parameter's usage is inspected. If set, $_ and $PSItem count towards it's usage when seen in a process block.
Fixes #1840
PR Checklist
- PR has a meaningful title
- Use the present tense and imperative mood when describing your changes
- Summarized changes
- Change is not breaking
- Make sure all
.cs,.ps1and.psm1files have the correct copyright header - Make sure you've added a new test if existing tests do not effectively test the code changed and/or updated documentation
- This PR is ready to merge and is not Work in Progress.
- If the PR is work in progress, please add the prefix
WIP:to the beginning of the title and remove the prefix when the PR is ready.
- If the PR is work in progress, please add the prefix
auto-merge was automatically disabled
Head branch was pushed to by a user without write access
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks, retriggered CI
…t directly contains variable usage of $_ or $PSItem. Then when we encounted a parameter with ValueFromPipeline set, we consider whether we saw usage within a process block by automatic variable.
liamjpeters
deleted the
#1840PSReviewUnusedParameterVsValueFromPipeline
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters