PSScriptAnalyzer icon indicating copy to clipboard operation
PSScriptAnalyzer copied to clipboard

UseConsistentWhitespace.CheckOperator: Add unary operators that start with a dash (-split, -join, -not, -bnot, isplit, csplit)

Open bergmeister opened this issue 4 years ago • 2 comments

PR Summary

Related: #1239

In order to enable formatting corrections of this kind: $a-join$b --> $a -join $b or reducing too much whitespace but also -split$a --> -split $a with the added code as existing code for operators assumes that something precedes it. The reason for adding the check that the unary operator starts with a dash is is to exclude things like $a++ or !$a where we do not want a whitespace character separation by default

PR Checklist

bergmeister avatar Oct 24 '20 21:10 bergmeister

I tried this code out and noticed a couple things. Checking that the operator starts with a dash introduces the following undesirable behavior: --$counter is changed to -- $counter. Also $counter-- is changed to $counter -- Unary operator -not does not get spacing if it follows a parenthesis such as if (-not$SomeVariable).

daviesj avatar Oct 27 '20 07:10 daviesj

Converting to draft to resolve the various PRs

rjmholt avatar Apr 21 '21 20:04 rjmholt