Skip to content

$FormatEnumerationLimit triggers PSAvoidGlobalVars warning #1756

@ssudnits

Description

@ssudnits

Steps to reproduce

Run PSSA against the following code:

function Test-FormatLimitGlobal
{
  # Change format enum limit Globally
  $Old = $Global:FormatEnumerationLimit
  $Global:FormatEnumerationLimit = 1
  "After changing: [$Global:FormatEnumerationLimit]"
  Get-Process | Select-Object -Property Name, Threads -First 4
  # Change it back
  $Global:FormatEnumerationLimit = $Old
}

Expected behavior

PSSA does not trigger any warning against FormatEnumerationLimit

Actual behavior

"Found global variable 'Global:FormatEnumerationLimit'." warning issued for every use of FormatEnumerationLimit

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.18362.1801
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.1801
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.20.0

Shouldn't FormatEnumerationLimit be in SpecialVars.cs with the rest of built-ins?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions