Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule PSReservedParams generates Warning instead of Error #1973

Open
pulkownik1803 opened this issue Feb 28, 2024 · 2 comments · May be fixed by #1989
Open

Rule PSReservedParams generates Warning instead of Error #1973

pulkownik1803 opened this issue Feb 28, 2024 · 2 comments · May be fixed by #1989

Comments

@pulkownik1803
Copy link

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
@SydneyhSmith SydneyhSmith changed the title Rule PSReservedParams generates Warning instead if Error Rule PSReservedParams generates Warning instead of Error Mar 27, 2024
@SydneyhSmith
Copy link
Collaborator

Thanks @pulkownik1803

@bergmeister
Copy link
Collaborator

bergmeister commented Apr 9, 2024

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants