Skip to content

PSUseConsistentWhitespace is not consistent with hash @{} and array @() #1346

Closed
@steveredden

Description

@steveredden

Steps to reproduce

Simple example:

$Array = @(); $Array.Count
$Hash = @{}; $Hash.Count

With a lint.psd1 of:

@{
    IncludeDefaultRules = $True
    Rules = @{
        PSUseConsistentWhitespace = @{
            Enable = $True
        }
    }
}

Execute

Invoke-ScriptAnalyzer -Path tmp.ps1 -settings lint.psd1

Expected behavior

I would expect

  1. Empty hash declarations to not cause a whitespace warning
    OR
  2. Empty array declarations to follow the same guidelines of empty hash declarations (requiring a space)

I would prefer option 1.

Actual behavior

image

Environment data

PS C:\tmp> System.Collections.Hashtable

Name                           Value                                                                                                                                                                                                 
----                           -----                                                                                                                                                                                                 
PSVersion                      5.1.17763.503                                                                                                                                                                                         
PSEdition                      Desktop                                                                                                                                                                                               
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                               
BuildVersion                   10.0.17763.503                                                                                                                                                                                        
CLRVersion                     4.0.30319.42000                                                                                                                                                                                       
WSManStackVersion              3.0                                                                                                                                                                                                   
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                   
SerializationVersion           1.1.0.1                                                                                                                                                                                               

PS C:\tmp> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { .ToString()}
1.18.3

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