PowerShell / PowerShell/PSScriptAnalyzer
variable assignments are not aligned
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
After executing the following code, the = in variable assignments are not aligned, and the = in the first hashtable are also not aligned. I tested this in PowerShell 5.1 on Windows 10.
cls
$s = @'
$hashtable = @{ property1 ="value"
anotherProperty= "another value"
}
$hashtable = @{
property1 = "value"
anotherProperty = "another value"
}
$hashtable = @{
property1 = "value"
anotherProperty = "another value"
}
$a= "hello"
$ccc = "world"
$b="Hi"
function foo {
"hello"
}
'@
$settings = @{
IncludeRules = @("PSPlaceOpenBrace", "PSUseConsistentIndentation", "PSUseConsistentWhitespace","PSAlignAssignmentStatement")
Rules = @{
PSPlaceOpenBrace = @{
Enable = $true
OnSameLine = $false
}
PSUseConsistentIndentation = @{
Enable = $true
Kind = 'tab' # space,tab
IndentationSize = 1
PipelineIndentation = 'NoIndentation'
}
PSAlignAssignmentStatement = @{
Enable = $true
CheckHashtable = $true
}
}
}
Invoke-Formatter -ScriptDefinition $s -Settings $settings
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the provided PowerShell 5.1 reproduction with PSAlignAssignmentStatement enabled, including CheckHashtable. Read the formatter behavior for that rule and compare the alignment of the assignments and hashtable entries; done means the demonstrated variable assignments and hashtable equals signs are aligned consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100