Skip to content

Rule PSReservedParams generates Warning instead of Error #1973

Description

@pulkownik1803

PSScriptAnalyzer reports PSReservedParams as warning but according to the documentation it's error

Steps to reproduce

function Test-Function {
    [CmdletBinding()]
    param (
        # Error
        [Parameter()]
        [string]
        $ErrorVariable
    )
    $ErrorVariable = 'Error'
}

> Invoke-ScriptAnalyzer -Path .\Test-Function.ps1

Expected behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSReservedParams                    Error        Test-Funct 5     'Test-Function' defines the reserved common parameter       
                                                 ion.ps1          'ErrorVariable'.

Actual behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSReservedParams                    Warning      Test-Funct 5     'Test-Function' defines the reserved common parameter       
                                                 ion.ps1          'ErrorVariable'.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.22621.2506
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.2506
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.21.0

Activity

  1. changed the title [-]Rule PSReservedParams generates Warning instead if Error[/-] [+]Rule PSReservedParams generates Warning instead of Error[/+] on Mar 27, 2024
  2. SydneyhSmith commented on Mar 27, 2024

    @SydneyhSmith
    Collaborator
  3. bergmeister commented on Apr 9, 2024

    @bergmeister
    Collaborator

    Thanks, I think it's best to fix code like you did rather than documentation because for this rule, violations result in code that won't even run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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