Skip to content

Commit 6631983

Browse files
author
Kapil Borle
committed
Parse string literal as argument in settings file
1 parent ba172a6 commit 6631983

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

Engine/Settings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,15 @@ private Hashtable GetHashtableFromHashTableAst(HashtableAst hashTableAst)
416416
var strConstExprAst = constExprAst as StringConstantExpressionAst;
417417
if (strConstExprAst != null)
418418
{
419-
rhsList.Add(strConstExprAst.Value);
419+
// it is a string literal
420+
output[key] = strConstExprAst.Value;
420421
}
421422
else
422423
{
423424
// it is either an integer or a float
424425
output[key] = constExprAst.Value;
425-
continue;
426426
}
427+
continue;
427428
}
428429
else if (pureExp is HashtableAst)
429430
{

Tests/Engine/Settings.tests.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Describe "Settings Class" {
9999
}
100100

101101
It "Should return 1 rule argument" {
102-
$settings.RuleArguments.Count | Should Be 2
102+
$settings.RuleArguments.Count | Should Be 3
103103
}
104104

105105
It "Should parse boolean type argument" {
@@ -109,5 +109,9 @@ Describe "Settings Class" {
109109
It "Should parse int type argument" {
110110
$settings.RuleArguments["PSUseConsistentIndentation"]["IndentationSize"] | Should Be 4
111111
}
112+
113+
It "Should parse string literal" {
114+
$settings.RuleArguments["PSProvideCommentHelp"]["Placement"] | Should Be 'end'
115+
}
112116
}
113-
}
117+
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
@{
22
"IncludeRules" = @("PSAvoidUsingCmdletAliases", "PSAvoidUsingWriteHost", "PSUseConsistentIndentation")
33
"ExcludeRules" = @("PSShouldProcess", "PSAvoidUsingWMICmdlet", "PSUseCmdletCorrectly")
4-
"rules" = @{
5-
PSAvoidUsingCmdletAliases = @{
4+
"rules" = @{
5+
PSAvoidUsingCmdletAliases = @{
66
WhiteList = @("cd", "cp")
77
}
88

99
PSUseConsistentIndentation = @{
1010
Enable = $true
1111
IndentationSize = 4
1212
}
13+
14+
PSProvideCommentHelp = @{
15+
Enable = $true
16+
Placement = 'end'
17+
}
1318
}
14-
}
19+
}

0 commit comments

Comments
 (0)