Skip to content

Unable to use both AlignAssignmentStatement and UseConsistentWhitespace rules #769

Closed
@gaudreaj

Description

@gaudreaj

Hi,

It seems like it is not possible to use both AlignAssignmentStatement and UseConsistentWhitespace rules because the first contradicts the second. UseConsistentWhitespace is enforcing that only one space is used before the operator while AlignAssignmentStatement assert that all "=" operators are aligned. The only way the analyzer would not fail is that all the keys from the hashtable are the same length ;)

To reproduce:

  1. Create a script with the following code:
$hashtable = @{
    property1       = "value"
    anotherProperty = "another value"
}
  1. Run the analyzer with code formatting settings:
Invoke-ScriptAnalyzer -Path MyScript.ps1 -Settings CodeFormatting

You should see a PSUseConsistentWhitespace rule warning

No warning should be the expected result

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