process-block-for-pipeline
What it does
Section titled “What it does”Reports a function or script block with a parameter that has ValueFromPipeline or ValueFromPipelineByPropertyName and no process block. A filter counts as having one.
Why it matters
Section titled “Why it matters”Without a process block the body runs once, after the pipeline has finished, and sees only the last object that came in. The others are lost.
To fix, put the work in process { }.
Example
Section titled “Example”...function Get-Alias { }function Get-Series { }function Get-Name { param([Parameter(ValueFromPipeline)]$Item) $Item}function Get-Name2 {...Configuration
Section titled “Configuration”powershell: lint: rules: process-block-for-pipeline: warn # off (default), warn, errorEnabled by the presets: powershell/psscriptanalyzer.
Suppress one line with sudsy-disable-next-line process-block-for-pipeline in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| psscriptanalyzer | PSUseProcessBlockForPipelineCommand |
partial | A process block anywhere in the function text counts, a nested one too. |