Skip to content
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

Fix edge case of PSUseConsistentIndentation for non-default value (IncreaseIndentationForFirstPipeline/IncreaseIndentationAfterEveryPipeline) #1423

Merged
merged 5 commits into from Apr 4, 2020

Conversation

@bergmeister
Copy link
Collaborator

bergmeister commented Mar 2, 2020

PR Summary

Fixes #1406

The code assumed that the first pipe in a pipeline Ast is the last one on that line, which made the code not work in the following scenario (where it did not add the indentation in the 2nd line)

foo | bar |
    baz

Therefore add code to be able to determine the last pipe on the line were the first pipe occurs
cc @felixfbecker

PR Checklist

Copy link
Member

JamesWTruher left a comment

this looks fine

DiagnosticRecord = $violations[0]
CorrectionsCount = 1
ViolationText = "baz"
CorrectionText = (New-Object -TypeName String -ArgumentList $indentationUnit, ($indentationSize * 1)) + 'baz'

This comment has been minimized.

@JamesWTruher

JamesWTruher Mar 4, 2020 Member

this could also be written without using New-Object:

CorrectionText = ($indentationUnit * $indentationSize) + 'baz'

it's sort of a toss up as to which one is more readable

This comment has been minimized.

@bergmeister

bergmeister Apr 4, 2020 Author Collaborator

Good idea, thanks, I applied it, I could even remove the parenthesis because multiplication takes precedence over addition

@bergmeister bergmeister merged commit 128a9a2 into PowerShell:master Apr 4, 2020
12 checks passed
12 checks passed
PSScriptAnalyzer-CI Build #20200404.1 succeeded
Details
PSScriptAnalyzer-CI (Build Full_Build) Build Full_Build succeeded
Details
PSScriptAnalyzer-CI (Test Ubuntu_16_04) Test Ubuntu_16_04 succeeded
Details
PSScriptAnalyzer-CI (Test Ubuntu_18_04) Test Ubuntu_18_04 succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2016_PowerShell_5_1) Test Windows_Server2016_PowerShell_5_1 succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2016_PowerShell_Core) Test Windows_Server2016_PowerShell_Core succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2019_PowerShell_5_1) Test Windows_Server2019_PowerShell_5_1 succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2019_PowerShell_Core) Test Windows_Server2019_PowerShell_Core succeeded
Details
PSScriptAnalyzer-CI (Test macOS_10_14_Mojave) Test macOS_10_14_Mojave succeeded
Details
PSScriptAnalyzer-CI (Test macOS_10_15_Catalina) Test macOS_10_15_Catalina succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla All CLA requirements met.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.