Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

UseConsistentWhitespace/CheckOpenBrace false positive #1522

Copy link
Copy link
@metablaster

Description

@metablaster
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.