File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -191,15 +191,7 @@ private IEnumerable<DiagnosticRecord> FindHashtableViolations(TokenOperations to
191
191
continue ;
192
192
}
193
193
194
- var widestKeyExtent = extentTuples
195
- . Select ( t => t . Item1 )
196
- . Aggregate ( ( t1 , tAggregate ) =>
197
- {
198
- return TokenOperations . GetExtentWidth ( tAggregate ) > TokenOperations . GetExtentWidth ( t1 )
199
- ? tAggregate
200
- : t1 ;
201
- } ) ;
202
- var expectedStartColumnNumber = widestKeyExtent . EndColumnNumber + 1 ;
194
+ var expectedStartColumnNumber = extentTuples . Max ( x => x . Item1 . EndColumnNumber ) + 1 ;
203
195
foreach ( var extentTuple in extentTuples )
204
196
{
205
197
if ( extentTuple . Item2 . StartColumnNumber != expectedStartColumnNumber )
Original file line number Diff line number Diff line change @@ -55,6 +55,16 @@ $hashtable = @{
55
55
Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '
56
56
}
57
57
58
+ It " Should not crash if property name reaches further to the right than the longest property name (regression test for issue 1067)" {
59
+ $def = @'
60
+ $hashtable = @{ property1 = "value"
61
+ anotherProperty = "another value"
62
+ }
63
+ '@
64
+
65
+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $def - Settings $settings - ErrorAction Stop | Get-Count | Should - Be 0
66
+ }
67
+
58
68
It " Should ignore if a hashtable is empty" {
59
69
$def = @'
60
70
$x = @{ }
You can’t perform that action at this time.
0 commit comments