Skip to content

Extend UseConsistentWhitespace to pipe and curly braces #1065

Closed

Description

Usually, powershell scripts follow those coding rules:

  • Spaces around pipe
Get-ChildItem -Path $path | Where-Object { ... }
# And not
Get-ChildItem -Path $path|Where-Object { ... }
  • Spaces inside curly braces
Where-Object { $_.Name -eq "test" }
# And not
Where-Object {$_.Name -eq "test"}

The rule UseConsistentWhitespace is close to checking that. It already checks if there is a space between a keyword and a brace (CheckOpenBrace option), and if operators are surrounded by spaces (CheckOperator option).

Is it possible to add options to check those additional rules?

Activity

  1. bergmeister commented on Sep 3, 2018

    @bergmeister
    Collaborator

    Yes, this sounds like a reasonable request to add this option (and potentially enable it by default)

  2. bergmeister commented on Sep 25, 2018

    @bergmeister
    Collaborator

    FYI: I started to work on this.
    I am working on this branch here which can already detect violations of whitespaces inside curly braces and around pipes. I need to tweak it with the correct error messages and auto-correct suggestions. At the moment, the idea is to add 2 new options: CheckInnerBrace and CheckPipe. cc James Truher (@JamesWTruher)

  3. avalery commented on Sep 29, 2018

    @avalery
    Author

    Great ! It looks good like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions