Skip to content
Open
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
4 changes: 4 additions & 0 deletions Engine/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,10 @@ public static bool IsModuleManifest(string filepath, Version powershellVersion =
return false;
}
var map = GetMapFromHashtableAst(hast);
if (map == null)
{
return false;
}
var deprecatedKeys = GetDeprecatedModuleManifestKeys();
IEnumerable<string> allKeys;
if (powershellVersion != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,16 @@ Describe "MissingRequiredFieldModuleManifest" {
-OutVariable ruleViolation
$ruleViolation.Count | Should -Be 0
}

It "does not flag a PowerShell data file with a non-string key" {
Invoke-ScriptAnalyzer `
-Path "$PSScriptRoot/TestManifest/PowerShellDataFileNonStringKey.psd1" `
-IncludeRule "PSMissingModuleManifestField" `
-ErrorVariable ruleErrors `
-ErrorAction SilentlyContinue `
-OutVariable ruleViolation
$ruleErrors | Should -BeNullOrEmpty
$ruleViolation.Count | Should -Be 0
}
}
}
11 changes: 11 additions & 0 deletions Tests/Rules/AvoidUsingDeprecatedManifestFields.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,16 @@ Describe "AvoidUsingDeprecatedManifestFields" {
-OutVariable ruleViolation
$ruleViolation.Count | Should -Be 0
}

It "does not flag a PowerShell data file with a non-string key" {
Invoke-ScriptAnalyzer `
-Path "$PSScriptRoot/TestManifest/PowerShellDataFileNonStringKey.psd1" `
-IncludeRule "PSAvoidUsingDeprecatedManifestFields" `
-ErrorVariable ruleErrors `
-ErrorAction SilentlyContinue `
-OutVariable ruleViolation
$ruleErrors | Should -BeNullOrEmpty
$ruleViolation.Count | Should -Be 0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@{1="a"; 2="b"}
11 changes: 11 additions & 0 deletions Tests/Rules/UseToExportFieldsInManifest.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,16 @@ Describe "UseManifestExportFields" {
-OutVariable ruleViolation
$ruleViolation.Count | Should -Be 0
}

It "does not flag a PowerShell data file with a non-string key" {
Invoke-ScriptAnalyzer `
-Path "$PSScriptRoot/TestManifest/PowerShellDataFileNonStringKey.psd1" `
-IncludeRule "PSUseToExportFieldsInManifest" `
-ErrorVariable ruleErrors `
-ErrorAction SilentlyContinue `
-OutVariable ruleViolation
$ruleErrors | Should -BeNullOrEmpty
$ruleViolation.Count | Should -Be 0
}
}
}