Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions Engine/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,6 @@ private Hashtable GetHashtableFromHashTableAst(HashtableAst hashTableAst)
}
}

if (rhsList.Count == 0)
{
ThrowInvalidDataException(kvp.Item2);
}

output[key] = rhsList.ToArray();
}

Expand Down Expand Up @@ -629,7 +624,7 @@ private List<string> GetArrayFromArrayExpressionAst(ArrayExpressionAst arrayExp)
}
}

return null;
return result;
}

private void ThrowInvalidDataException(Ast ast)
Expand Down
18 changes: 11 additions & 7 deletions Tests/Engine/Settings.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,23 @@ Describe "Settings Precedence" {

Describe "Settings Class" {
Context "When an empty hashtable is provided" {
BeforeAll {
$settings = New-Object -TypeName $settingsTypeName -ArgumentList @{}
}

It "Should return empty <name> property" -TestCases @(
@{ Name = "IncludeRules" }
@{ Name = "ExcludeRules" }
@{ Name = "Severity" }
@{ Name = "RuleArguments" }
) {
Param($Name)
) {
Param($Name)

${settings}.${Name}.Count | Should -Be 0
$settings = New-Object -TypeName $settingsTypeName -ArgumentList @{}
${settings}.${Name}.Count | Should -Be 0
}

It "Should be able to parse empty settings hashtable from settings file" {
$testPSSASettingsFilePath = "TestDrive:\PSSASettings.psd1"
Set-Content $testPSSASettingsFilePath -Value '@{ExcludeRules = @()}'
Invoke-ScriptAnalyzer -ScriptDefinition 'gci' -Settings $testPSSASettingsFilePath | Should -Not -BeNullOrEmpty
}
}

Expand Down Expand Up @@ -104,7 +108,7 @@ Describe "Settings Class" {
It "Should return $expectedNumberOfIncludeRules IncludeRules" {
$settings.IncludeRules.Count | Should -Be $expectedNumberOfIncludeRules
}

$expectedNumberOfExcludeRules = 3
It "Should return $expectedNumberOfExcludeRules ExcludeRules" {
$settings.ExcludeRules.Count | Should -Be $expectedNumberOfExcludeRules
Expand Down