Skip to content

UseConsistentWhitespace/CheckOpenBrace false positive #1522

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

Closed
metablaster opened this issue Jun 12, 2020 · 2 comments
Closed

UseConsistentWhitespace/CheckOpenBrace false positive #1522

metablaster opened this issue Jun 12, 2020 · 2 comments

Comments

@metablaster
Copy link

metablaster commented Jun 12, 2020

Steps to reproduce

Here is setting snapshot I'm trying to use:

@{
IncludeRules = @(
       'PSUseConsistentWhitespace')

Rules = @{
        PSUseConsistentWhitespace = @{
	         # Checks if there is a space between a keyword and its corresponding open brace.
	         # E.g. foo { } instead of foo{ }
	         # default = true (powershell.codeFormatting.whitespaceBeforeOpenBrace)
	         CheckOpenBrace = $true
        }
}

And here is sample test function, not that open brace is not new line!

function Test-Foo()
{
}

Expected behavior

No warning is shown for bellow function

# NO WARNING HERE
function Test-Foo()
{
}

Actual behavior

Warning is shown because brace is on next line, there is no need for any space here,
This warning is valid only if open brace is on same line as function name.

# PSUseConsistentWhitespace   Warning  Use space before open brace.
function Test-Foo()
{
}

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0
@bergmeister
Copy link
Collaborator

bergmeister commented Jun 13, 2020

Thanks for taking the time to report it. I can verify this happens with 1.19.0 but I am happy to say we have fixed this in master already by PR #1491
We will briefly discuss this issue at the next triage session since there are also other recently fixed cases that would warrant releasing some of the recent fixes in a new patch release, therefore expect this issue to get closed soon but you'll have to wait for the next release in the meantime.

@metablaster
Copy link
Author

Thank you for quick response!
Glad to hear it's already resolved.

@ghost ghost closed this as completed Jun 22, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants