FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix edge case of PSUseConsistentIndentation for non-default value (IncreaseIndentationForFirstPipeline/IncreaseIndentationAfterEveryPipeline) by bergmeister · Pull Request #1423 · PowerShell/PSScriptAnalyzer · GitHub

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

Merged
Christoph Bergmeister (bergmeister) merged 5 commits into
PowerShell:masterfrom
bergmeister:issue1406
Apr 4, 2020
Merged

Conversation

Christoph Bergmeister (bergmeister) commented Mar 2, 2020
edited
Loading

Copy link
Copy Markdown
Collaborator

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 Felix Becker (@felixfbecker)

PR Checklist

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

this looks fine

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Christoph Bergmeister (bergmeister) merged commit 128a9a2 into PowerShell:master Apr 4, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PSUseConsistentIndentation: Identation missing if command was broken over multiple lines

3 participants


Back | FazBrowse Home | New Git URL