X Tutup
The Wayback Machine - https://web.archive.org/web/20200918095142/https://github.com/PowerShell/PSScriptAnalyzer/pull/1235
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent PSCloseBrace crash if hashtable definition start on first token and there is a PSCloseBrace violation #1235

Merged
merged 3 commits into from Jun 6, 2019

Conversation

@bergmeister
Copy link
Collaborator

bergmeister commented May 5, 2019

PR Summary

Fixes #1219

PR Checklist

…is a PSCloseBrace violation
@rjmholt
rjmholt approved these changes May 6, 2019
Copy link
Member

rjmholt left a comment

LGTM!

Copy link
Member

JamesWTruher left a 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 = @'

This comment has been minimized.

@JamesWTruher

JamesWTruher May 16, 2019 Member

I think this can also be written as follows:

$def = "@{ `n Key = 1 }"

and it will cause the same error

This comment has been minimized.

@JamesWTruher

JamesWTruher May 16, 2019 Member

and it's a very specific set of characters. This "@{key=1}" doesn't cause the problem but "@{``nkey=1}" does

This comment has been minimized.

@bergmeister

bergmeister May 29, 2019 Author Collaborator

Ok, I can change it to that

This comment has been minimized.

@bergmeister

bergmeister Jun 5, 2019 Author Collaborator

Done now

$violations.Count | Should -Be 1
Invoke-Formatter -ScriptDefinition $def -ErrorAction Stop

This comment has been minimized.

@JamesWTruher

JamesWTruher May 16, 2019 Member

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?)

This comment has been minimized.

@bergmeister

bergmeister May 29, 2019 Author Collaborator

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.

@JamesWTruher JamesWTruher merged commit c3f2a20 into PowerShell:development Jun 6, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla All CLA requirements met.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.
X Tutup