Skip to content

Extend UseConsistentWhitespace to pipe and curly braces #1065

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
avalery opened this issue Sep 3, 2018 · 3 comments · Fixed by #1092
Closed

Extend UseConsistentWhitespace to pipe and curly braces #1065

avalery opened this issue Sep 3, 2018 · 3 comments · Fixed by #1092
Assignees

Comments

@avalery
Copy link

avalery commented Sep 3, 2018

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?

@bergmeister
Copy link
Collaborator

bergmeister commented Sep 3, 2018

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

@bergmeister
Copy link
Collaborator

bergmeister commented Sep 25, 2018

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 @JamesWTruher

@avalery
Copy link
Author

avalery commented Sep 29, 2018

Great ! It looks good like this.

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

Successfully merging a pull request may close this issue.

2 participants