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

Fix PSUseConsistentIndentation.PipelineIndentation.None to not remove code when the previous line ended with a pipe by bergmeister · Pull Request #1746 · PowerShell/PSScriptAnalyzer · GitHub

Fix PSUseConsistentIndentation.PipelineIndentation.None to not remove code when the previous line ended with a pipe - #1746

Merged
James Truher (JamesWTruher) merged 2 commits into
PowerShell:masterfrom
bergmeister:fix_1580
May 24, 2022
Merged

Fix PSUseConsistentIndentation.PipelineIndentation.None to not remove code when the previous line ended with a pipe#1746
James Truher (JamesWTruher) merged 2 commits into
PowerShell:masterfrom
bergmeister:fix_1580

Conversation

Copy link
Copy Markdown
Collaborator

PR Summary

Fixes #1580 by resetting the newline in the case of the first token after a pipeline and newline lands in the default switch statement. It seems the existing test case was too simple.

PR Checklist

Christoph Bergmeister (bergmeister) marked this pull request as ready for review November 13, 2021 19:20

Copy link
Copy Markdown
Member

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

Thank you for working on this Christoph Bergmeister (@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.

Christoph Bergmeister (bergmeister) commented Nov 22, 2021
edited
Loading

Copy link
Copy Markdown
Collaborator Author

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.
With regards to the repro also working for 3, this is in fact the same setting, it is just the enum representation of it:

[ConfigurableRuleProperty(defaultValue: "IncreaseIndentationForFirstPipeline")]
public string PipelineIndentation
{
get
{
return pipelineIndentationStyle.ToString();
}
set
{
if (String.IsNullOrWhiteSpace(value) ||
!Enum.TryParse(value, true, out pipelineIndentationStyle))
{
pipelineIndentationStyle = PipelineIndentationStyle.IncreaseIndentationForFirstPipeline;
}
}
}
private bool insertSpaces;
private char indentationChar;
private int indentationLevelMultiplier;
// TODO Enable auto when the rule is able to detect indentation
private enum IndentationKind {
Space,
Tab,
// Auto
};
private enum PipelineIndentationStyle
{
IncreaseIndentationForFirstPipeline,
IncreaseIndentationAfterEveryPipeline,
NoIndentation,
None
}

Copy link
Copy Markdown
Member

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

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!

James Truher (JamesWTruher) merged commit 4890939 into PowerShell:master May 24, 2022
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PSUseConsistentIndentation.PipelineIndentation.None or 3 deletes commandlet name

3 participants


Back | FazBrowse Home | New Git URL