FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

PSReviewUnusedParameter false positive for ValueFromPipeline by liamjpeters · Pull Request #2072 · PowerShell/PSScriptAnalyzer · GitHub

PSReviewUnusedParameter false positive for ValueFromPipeline - #2072

Merged
Andy Jordan (andyleejordan) merged 5 commits into
PowerShell:mainfrom
liamjpeters:#1840PSReviewUnusedParameterVsValueFromPipeline
Mar 13, 2025
Merged

PSReviewUnusedParameter false positive for ValueFromPipeline#2072
Andy Jordan (andyleejordan) merged 5 commits into
PowerShell:mainfrom
liamjpeters:#1840PSReviewUnusedParameterVsValueFromPipeline

Conversation

Liam Peters (liamjpeters) commented Mar 3, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

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

Comment thread Rules/ReviewUnusedParameter.cs Outdated
Andy Jordan (andyleejordan) enabled auto-merge (squash) March 6, 2025 20:00
auto-merge was automatically disabled March 10, 2025 19:30

Head branch was pushed to by a user without write access

Christoph Bergmeister (bergmeister) left a comment
edited
Loading

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.
Co-authored-by: Andy Jordan <2226434+andyleejordan@users.noreply.github.com>
Andy Jordan (andyleejordan) force-pushed the #1840PSReviewUnusedParameterVsValueFromPipeline branch from 95e1486 to d83b1d9 Compare March 13, 2025 17:05
Andy Jordan (andyleejordan) merged commit 1d394ee into PowerShell:main Mar 13, 2025
Liam Peters (liamjpeters) deleted the #1840PSReviewUnusedParameterVsValueFromPipeline branch August 7, 2025 12:45
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PSReviewUnusedParameter false positive for ValueFromPipeline and current process item $_

3 participants


Back | FazBrowse Home | New Git URL