Skip to content

PSAlignAssignmentStatement returns SuggestedCorrections with wrong format #2201

Description

@teanup

Steps to reproduce

Trigger a rule violation of PSAlignAssignmentStatement with unaligned assignments:

"@{`n    test = 1`n    test2 = 2`n}" | Set-Content -Path test.ps1
Invoke-ScriptAnalyzer -Path ./test.ps1 -Settings CodeFormattingOTBS | Select-Object -ExpandProperty SuggestedCorrections

Expected behavior

Like all other rules, the CorrectionExtent object should have the file path as File property and the correction description as Description property.

File              : /path/to/test.ps1
Description       : Assignment statements are not aligned
StartLineNumber   : 2
StartColumnNumber : 9
EndLineNumber     : 2
EndColumnNumber   : 10
Text              :   
Lines             : {  }
Start             : Microsoft.Windows.PowerShell.ScriptAnalyzer.Position
End               : Microsoft.Windows.PowerShell.ScriptAnalyzer.Position

Actual behavior

Instead, Description is null and File contains the description.

File              : Assignment statements are not aligned
Description       : 
StartLineNumber   : 2
StartColumnNumber : 9
EndLineNumber     : 2
EndColumnNumber   : 10
Text              :   
Lines             : {  }
Start             : Microsoft.Windows.PowerShell.ScriptAnalyzer.Position
End               : Microsoft.Windows.PowerShell.ScriptAnalyzer.Position

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.6.2
PSEdition                      Core
GitCommitId                    7.6.2
OS                             Ubuntu 24.04.4 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }

1.25.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions