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 PSUseConsistentIndentation.PipelineIndentation.None to not remove code when the previous line ended with a pipe #1746

Merged
merged 2 commits into from
May 24, 2022

Conversation

bergmeister
Copy link
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

@bergmeister bergmeister marked this pull request as ready for review November 13, 2021 19:20
Copy link
Member

@andyleejordan andyleejordan left a comment

Choose a reason for hiding this comment

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

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.

@bergmeister
Copy link
Collaborator Author

bergmeister commented Nov 22, 2021

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
Member

@andyleejordan andyleejordan left a comment

Choose a reason for hiding this comment

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

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!

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