Skip to content

1.x: Fix wiring of WhitespaceInsideBrace and WhitespaceAroundPipe that got broken in #1024 #1142

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

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -249,58 +249,62 @@ public Hashtable GetPSSASettingsHashtable(

private Hashtable GetCustomPSSASettingsHashtable(int tabSize, bool insertSpaces)
{
var ruleConfigurations = new Hashtable {
{"PSPlaceOpenBrace", new Hashtable {
{"Enable", true},
{"OnSameLine", OpenBraceOnSameLine},
{"NewLineAfter", NewLineAfterOpenBrace},
{"IgnoreOneLineBlock", IgnoreOneLineBlock}
var ruleConfigurations = new Hashtable
{
{ "PSPlaceOpenBrace", new Hashtable {
{ "Enable", true },
{ "OnSameLine", OpenBraceOnSameLine },
{ "NewLineAfter", NewLineAfterOpenBrace },
{ "IgnoreOneLineBlock", IgnoreOneLineBlock }
}},
{"PSPlaceCloseBrace", new Hashtable {
{"Enable", true},
{"NewLineAfter", NewLineAfterCloseBrace},
{"IgnoreOneLineBlock", IgnoreOneLineBlock}
{ "PSPlaceCloseBrace", new Hashtable {
{ "Enable", true },
{ "NewLineAfter", NewLineAfterCloseBrace },
{ "IgnoreOneLineBlock", IgnoreOneLineBlock }
}},
{"PSUseConsistentIndentation", new Hashtable {
{"Enable", true},
{"IndentationSize", tabSize},
{"PipelineIndentation", PipelineIndentationStyle },
{"Kind", insertSpaces ? "space" : "tab"}
{ "PSUseConsistentIndentation", new Hashtable {
{ "Enable", true },
{ "IndentationSize", tabSize },
{ "PipelineIndentation", PipelineIndentationStyle },
{ "Kind", insertSpaces ? "space" : "tab" }
}},
{"PSUseConsistentWhitespace", new Hashtable {
{"Enable", true},
{"CheckOpenBrace", WhitespaceBeforeOpenBrace},
{"CheckOpenParen", WhitespaceBeforeOpenParen},
{"CheckOperator", WhitespaceAroundOperator},
{"CheckSeparator", WhitespaceAfterSeparator}
{ "PSUseConsistentWhitespace", new Hashtable {
{ "Enable", true },
{ "CheckOpenBrace", WhitespaceBeforeOpenBrace },
{ "CheckOpenParen", WhitespaceBeforeOpenParen },
{ "CheckOperator", WhitespaceAroundOperator },
{ "CheckSeparator", WhitespaceAfterSeparator },
{ "CheckInnerBrace", WhitespaceInsideBrace },
{ "CheckPipe", WhitespaceAroundPipe },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line and the line above is the essential fix

}},
{"PSAlignAssignmentStatement", new Hashtable {
{"Enable", true},
{"CheckHashtable", AlignPropertyValuePairs}
{ "PSAlignAssignmentStatement", new Hashtable {
{ "Enable", true },
{ "CheckHashtable", AlignPropertyValuePairs }
}},
{"PSUseCorrectCasing", new Hashtable {
{"Enable", UseCorrectCasing}
{ "PSUseCorrectCasing", new Hashtable {
{ "Enable", UseCorrectCasing }
}},
};

if (AutoCorrectAliases)
{
// Empty hashtable required to activate the rule,
// since PSAvoidUsingCmdletAliases inherits from IScriptRule and not ConfigurableRule
ruleConfigurations.Add("PSAvoidUsingCmdletAliases", new Hashtable());
}

return new Hashtable
return new Hashtable()
{
{"IncludeRules", new string[] {
"PSPlaceCloseBrace",
"PSPlaceOpenBrace",
"PSUseConsistentWhitespace",
"PSUseConsistentIndentation",
"PSAlignAssignmentStatement",
"PSAvoidUsingCmdletAliases",
Copy link
Contributor Author

@bergmeister bergmeister Jan 3, 2020

Choose a reason for hiding this comment

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

This entry (the removed PSAvoidUsingCmdletAliases) is actually not necessary and was removed in PR #1056 in master, hence why this change is also brought back as well as the essential required thing is ruleConfigurations.Add("PSAvoidUsingCmdletAliases", new Hashtable()); a few lines above here for the autoCorrectAliases feature to work

{ "IncludeRules", new string[] {
"PSPlaceCloseBrace",
"PSPlaceOpenBrace",
"PSUseConsistentWhitespace",
"PSUseConsistentIndentation",
"PSAlignAssignmentStatement",
}},
{
"Rules", ruleConfigurations
},
}
};
}
}
Expand Down