Skip to content
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