Skip to content

PSUseConsistentWhitespace complains when consecutive assignment operations are aligned #1460

Closed
@peetrike

Description

@peetrike

Before submitting a bug report:

  • Make sure you are able to repro it on the latest released version
  • Perform a quick search for existing issues to check if this bug has already been reported

Steps to reproduce

Invoke-ScriptAnalyzer -ScriptDefinition @'
$e      = 3
$longer = $e
$h = @{
    a    = $longer
    long = 2
}
$h
'@ -Settings @{
    Rules = @{
        PSUseConsistentWhitespace  = @{
            Enable = $true
        }
    }
}

Expected behavior

When assignment operators are aligned, the PSUseConsistentWhitespace rule should not complain that there are more than one space before equal sign.

Actual behavior

RuleName                  Severity ScriptName Line Message
--------                  -------- ---------- ---- -------
PSUseConsistentWhitespace Warning             1    Use space before and after binary and assignment operators.
PSUseConsistentWhitespace Warning             4    Use space before and after binary and assignment operators.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.18362.752
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.752
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.18.3
> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (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