Skip to content

PSUseConsistantWhiteSpace #2089

@AlexandraDorey

Description

@AlexandraDorey

Steps to reproduce

Attaching our PSD fille for the analyzer config

We have

PSUseConsistentWhitespace with IgnoreAssignmentOperatorInsideHashTable = $true
PSAlignAssignmentStatement with Enabled = $true and CheckHashTable = $true

It generally works as advertised... except...

When a using statement is present... we get a "Use space before and after binary and assignment operators.PSScriptAnalyzer(PSUseConsistentWhitespace)" error.

This does not work ...

using namespace DoesNotMatter

$SoSad = @{
    not     = 'other'
    theSame = 'casting sucks maybe?'
}

This works in our setup...

$SoHappy= @{
    not     = 'other'
    theSame = 'casting sucks.'
}

``
![Image](https://github.com/user-attachments/assets/d7e4d67f-8fdb-4ab3-8ede-a496db5c7f6b)

Expected behavior
-----------------
 
No linting error.

Actual behavior
---------------

Seems to check inside hashtables when a using statement of ANY kind is present. The fixer works still though so it doesn't feel like something inherent with the type, maybe something to do with how using are tokenized? 

D:\Symphony\devops-scripts\Symphony\Symphony.Azdo\Happy.ps1
Environment dataD:\Symphony\devops-scripts\Symphony\Symphony.Azdo\Sad.ps1
----------------

Present in a bunch of envs including our build farm...and using the latest version (1.24.0)

Attaching file

[PSScriptAnalyzerSettings.txt](https://github.com/user-attachments/files/19352089/PSScriptAnalyzerSettings.txt)

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