Skip to content

UseProcessBlockForPipelineCommand returns a warning when pipeline behavior is explicitly disabled #1725

Open
@Glober777

Description

@Glober777

I've noticed that UseProcessBlockForPipelineCommand rule produces warning notifications when pipeline behavior (ValueFromPipeline, ValueFromPipelineByPropertyName) is explicitly disabled.

Steps to reproduce

Function Get-Number
{
    [CmdletBinding()]
    [OutputType([int])]
    Param(
        [Parameter(ValueFromPipeline=$false)]
        [int]
        $Number
    )

    $Number
}

Expected behavior

The rule should not report any findings

Actual behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSUseProcessBlockForPipelineCommand Warning      Test-PSSA. 8     Command accepts pipeline input but has not defined a
                                                 ps1              process block.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.19042
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.1
1.20.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions