PSUseConsistentIndentation: Indentation wrong if pipeline is wrapped in parentheses
Before submitting a bug report:
- Make sure you are able to repro it on the latest released version
- Perform a quick search for existing issues to check if this bug has already been reported
Steps to reproduce
Format one of these files:
https://github.com/pcgeek86/PSGitHub/blob/5fa152568f3218843bbec97c5604d6b16b03066f/Functions/Private/ConvertTo-ColoredPatch.ps1
https://github.com/pcgeek86/PSGitHub/blob/5fa152568f3218843bbec97c5604d6b16b03066f/Functions/Public/Merge-GitHubPullRequest.ps1
https://github.com/pcgeek86/PSGitHub/blob/5fa152568f3218843bbec97c5604d6b16b03066f/Functions/Public/New-GitHubReleaseAsset.ps1
https://github.com/pcgeek86/PSGitHub/blob/5fa152568f3218843bbec97c5604d6b16b03066f/Functions/Public/New-GitHubReview.ps1
https://github.com/pcgeek86/PSGitHub/blob/5fa152568f3218843bbec97c5604d6b16b03066f/Functions/Public/Set-GitHubToken.ps1
with
@{ Severity = @('Error', 'Warning', 'Information') ExcludeRules = @( 'PSUseShouldProcessForStateChangingFunctions' # TODO: implement ShouldProcess ) Rules = @{ PSPlaceOpenBrace = @{ Enable = $true OnSameLine = $true NewLineAfter = $true IgnoreOneLineBlock = $true } PSPlaceCloseBrace = @{ Enable = $true NewLineAfter = $false IgnoreOneLineBlock = $true NoEmptyLineBefore = $true } PSUseConsistentIndentation = @{ Enable = $true Kind = 'space' IndentationSize = 4 PipelineIndentation = 'IncreaseIndentationForFirstPipeline' } PSUseConsistentWhitespace = @{ Enable = $true CheckOpenBrace = $true CheckOpenParen = $true CheckOperator = $true CheckSeparator = $true } PSAlignAssignmentStatement = @{ Enable = $false } PSUseCorrectCasing = @{ Enable = $true } } }
Expected behavior
Should stay the same
Actual behavior
Following indentation is too much, one for every pair of () it seems, e.g.:
if ($UploadUrl -match '\{\?(.+)\}') { $vars = @{ name = $name; label = $Label } $allowedVars = $Matches[1] -split ',' $query = '?' + (($allowedVars | ForEach-Object { if ($vars.ContainsKey($_)) { $value = [System.Web.HttpUtility]::UrlEncode($vars[$_]) "$_=$value" } }) -join '&') $UploadUrl = $UploadUrl -replace '\{\?.+\}', $query }
Environment data
Name Value ---- ----- PSVersion 6.2.4 PSEdition Core GitCommitId 6.2.4 OS Darwin 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov 9 03:47:04 PST 2019; root:xnu-6153… Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0 1.18.3