Fix PSUseConsistentIndentation.PipelineIndentation.None to not remove code when the previous line ended with a pipe#1746
Conversation
andyleejordan
left a comment
There was a problem hiding this comment.
Thank you for working on this @bergmeister. I'm wondering if we need a few more tests? #1580 provided several examples, and also pointed out that this issue occurs with both None and strangely a setting of 3. What do you think?
I can spend some time to manually test this if you'd like and perhaps come up with more test coverage.
|
Yes, testing is always a challenge. It's a compromise between doing lots of integration tests or complex code and maintaining all the test cases if a change necessitates updating expectations. Definitely happy to add more test cases or something more complex, do you have something specific in mind? Otherwise my suggestions is to dog food the local build with this setting. PSScriptAnalyzer/Rules/UseConsistentIndentation.cs Lines 61 to 95 in 58c4423 |
andyleejordan
left a comment
There was a problem hiding this comment.
With regards to the repro also working for 3, this is in fact the same setting, it is just the enum representation of it:
Gotcha! In that case, I'll defer to your judgement. Looks good to me!
PR Summary
Fixes #1580 by resetting the newline in the case of the first token after a pipeline and newline lands in the
defaultswitch statement. It seems the existing test case was too simple.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.