Skip to content

PSAvoidAssignmentToAutomaticVariable finds auto variable in RHS when assigning to a static property #1013

Closed
@SeeminglyScience

Description

@SeeminglyScience

Steps to reproduce

Invoke-ScriptAnalyzer -ScriptDefinition '[System.Console]::CursorVisible = $true'

Expected behavior

The rule is not triggered

Actual behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSAvoidAssignmentToAutomaticVariable Error                  1     The Variable 'true' cannot be assigned since it is a
                                                                  readonly automatic variable that is built into
                                                                  PowerShell, please use a different name.

Environment data

> $PSVersionTable
Name                           Value                                                                                                                                                         
----                           -----                                                                                                                                                         
PSVersion                      5.1.16299.251                                                                                                                                                 
PSEdition                      Desktop                                                                                                                                                       
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                       
BuildVersion                   10.0.16299.251                                                                                                                                                
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.17.0
1.13.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions