Prevent PSCloseBrace crash if hashtable definition start on first token and there is a PSCloseBrace violation#1235
Conversation
…is a PSCloseBrace violation
JamesWTruher
left a comment
There was a problem hiding this comment.
I'm not sure the call to Invoke-Formatter belongs in line 107
| } | ||
|
|
||
| It "Should not crash when hashtable is defined on first token" { | ||
| $def = @' |
There was a problem hiding this comment.
I think this can also be written as follows:
$def = "@{ `n Key = 1 }"
and it will cause the same error
There was a problem hiding this comment.
and it's a very specific set of characters. This "@{key=1}" doesn't cause the problem but "@{``nkey=1}" does
There was a problem hiding this comment.
Ok, I can change it to that
|
|
||
| $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings -ErrorAction Stop | ||
| $violations.Count | Should -Be 1 | ||
| Invoke-Formatter -ScriptDefinition $def -ErrorAction Stop |
There was a problem hiding this comment.
There doesn't seem to be an assertion here. Since the formatter uses the same rule, this seems superfluous. (do you want an explicit test for the formatter?)
There was a problem hiding this comment.
The assertion here is that the formatter does not throw an exception. The call to Invoke-ScriptAnalyzer is the core unit test but the call to Invoke-Formatter is the integration test.
PR Summary
Fixes #1219
PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.