Improve pipeline indentation handling in UseConsistentIndentation rule#2173
Open
liamjpeters wants to merge 2 commits intoPowerShell:mainfrom
Open
Improve pipeline indentation handling in UseConsistentIndentation rule#2173liamjpeters wants to merge 2 commits intoPowerShell:mainfrom
liamjpeters wants to merge 2 commits intoPowerShell:mainfrom
Conversation
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Two small improvements in the
UseConsistentIndentationrule's handing of pipeline indentation. Flagged in this issue and issue comment.Rule never finds the ends of nested pipelines, as it had a fast-return when it reached a pipeline who's end position was beyond the current tokens line. It would always find the outer/parent pipeline (which contains the nested pipeline and spans past it) and return early, empty-handed.
This would lead to some cases of "runaway" indents.
PR sorts the pipelines, in place, by their end line number and column number. This allows the nested pipeline to be found first (as they end before their parent pipeline).
Rule was using a single counter to keep track of pipeline indentation and then removing it all when it found a pipeline end.
There were some edge cases that were, even with the first issue resolved, not quite right.
PR adds in tracking of each pipeline's indentation contribution separately.
Copilot generated (and I reviewed) a bunch of tests to cover these cases. It's really getting quite good at generating tests now 🤖
Fixes #1933
PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.