Skip to content

PSUseConsistentWhitespace should not flag for comments after a separator #1842

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
fsackur opened this issue Sep 16, 2022 · 0 comments · Fixed by #2065
Closed

PSUseConsistentWhitespace should not flag for comments after a separator #1842

fsackur opened this issue Sep 16, 2022 · 0 comments · Fixed by #2065

Comments

@fsackur
Copy link

fsackur commented Sep 16, 2022

Summary of the new feature

Whitespace after a separator but before a comment should not be a violation of PSUseConsistentWhitespace

Proposed technical implementation details (optional)

test.ps1 (note whitespace between foo, and #):

function test {
    $Array = @(
        'foo',  # defined in RFC-666
        'bar'
    )
    $Array
}

Settings.psd1:

@{
    Rules = @{
        PSUseConsistentWhitespace = @{
            Enable         = $true
            CheckSeparator = $true
        }
    }
}

Current behaviour:

> Invoke-ScriptAnalyzer .\test.ps1 -Settings .\Settings.psd1

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSUseConsistentWhitespace           Warning      test.ps1   3     Use space after a comma.

Desired behaviour:

  • no violation

What is the latest version of PSScriptAnalyzer at the point of writing

1.20.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants