Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Rules/AlignAssignmentStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ int targetColumn
lhsExtent.EndColumnNumber,
equalsExtent.StartColumnNumber,
new string(' ', targetColumn - lhsExtent.EndColumnNumber),
lhsExtent.File,
string.Format(CultureInfo.CurrentCulture, Strings.AlignAssignmentStatementError)
)
};
Expand Down
15 changes: 15 additions & 0 deletions Tests/Rules/AlignAssignmentStatement.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ Configuration C1 {

Context 'When Hashtable checking is enabled' {

It 'Should set correction file and description when analyzing a file' {
$path = Join-Path -Path $TestDrive -ChildPath 'unaligned.ps1'
Set-Content -LiteralPath $path -Value '@{"Key" = "Value"}'

$settings = New-AlignAssignmentSettings -CheckHashtable $true

$violations = Invoke-ScriptAnalyzer -Path $path -Settings $settings |
Get-NonParseDiagnostics

$violations | Should -HaveCount 1
$correction = $violations[0].SuggestedCorrections[0]
$correction.File | Should -Be ([IO.Path]::GetFullPath($path))
$correction.Description | Should -Be 'Assignment statements are not aligned'
}

It 'Should not find violations in empty single-line hashtable' {
$def = '@{}'

Expand Down