Skip to content

PSUseConsistentWhitespace should not flag for comments after a separator #1842

@fsackur

Description

@fsackur

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions