Skip to content

Invoke-Formatter: Tab Issue #1055

@midacts

Description

@midacts
# CodeFormatting.psd1
@{
    IncludeRules = @(
        'PSPlaceOpenBrace',
        'PSPlaceCloseBrace',
        'PSUseConsistentWhitespace',
        'PSUseConsistentIndentation',
        'PSAlignAssignmentStatement'
    )

    Rules        = @{
        PSPlaceOpenBrace           = @{
            Enable             = $true
            OnSameLine         = $false
            NewLineAfter       = $true
            IgnoreOneLineBlock = $true
        }

        PSPlaceCloseBrace          = @{
            Enable             = $true
            NewLineAfter       = $true
            IgnoreOneLineBlock = $true
            NoEmptyLineBefore  = $false
        }

        PSUseConsistentIndentation = @{
            Enable          = $true
            **Kind            = 'tab'**
            IndentationSize = 4
        }

        PSUseConsistentWhitespace  = @{
            Enable         = $true
            CheckOpenBrace = $true
            CheckOpenParen = $true
            CheckOperator  = $true
            CheckSeparator = $true
        }

        PSAlignAssignmentStatement = @{
            Enable         = $true
            CheckHashtable = $true
        }
    }
}

Steps to reproduce

$Params = @{
	'AppName'		= "AppTest9001"
	'NTID'			= "TestNTID"
	'Credential'	= $Credential
	'Verbose'		= $True
}

Expected behavior

It should preserve tabs (anywhere) but in this case specifically, between the key and the equal sign

Actual behavior

It is changing out tabs for spaces between the key and equal sign.
Also, I noticed it is also did not convert some tabs to spaces. If there is only one tab between the key and equal sign, it didn't convert the tab to spaces. My guess is the tab isn't a full tab (meaning it would only be 1-3 spaces and not the full 4)

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.1155
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.1155
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.17.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions