Skip to content

Enhance PSUseConsistentWhiteSpace to exclude more special cases when using unary operators #950

Open
@bergmeister

Description

@bergmeister

Found when discussing PR #949 , which already tweaked PSUseConsistentWhiteSpace when using unary operators inside parenthesis.
This adds another special case where the rule should be excluded. The community is welcome to provide more cases that need to be treated specially.

Steps to reproduce

Invoke-Formatter -ScriptDefinition '$r = $a -lt -$var'                                                                                                       

Expected behavior

$r = $a -lt -$var

Actual behavior

$r = $a -lt - $var

Environment data

This applies also to the latest version of the development branch.

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.16299.251
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.251
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.16.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions