@@ -235,36 +235,36 @@ enum MyEnum {
235235 $matchingViolations [0 ].Message | Should - BeLike " *FunctionsToExport*wildcard*"
236236 }
237237
238- It " Should flag wildcard in CmdletsToExport " {
239- $manifestPath = Join-Path $tempPath " WildcardCmdlets .psd1"
238+ It " Should flag wildcard array in FunctionsToExport " {
239+ $manifestPath = Join-Path $tempPath " WildcardFunctions .psd1"
240240 $manifestContent = @'
241241@{
242242 ModuleVersion = '1.0.0'
243243 GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
244- CmdletsToExport = '*'
244+ FunctionsToExport = @( '*')
245245}
246246'@
247247 Set-Content - Path $manifestPath - Value $manifestContent
248248 $violations = Invoke-ScriptAnalyzer - Path $manifestPath - Settings $settings
249249 $matchingViolations = $violations | Where-Object { $_.RuleName -eq $violationName }
250250 $matchingViolations.Count | Should - BeGreaterThan 0
251- $matchingViolations [0 ].Message | Should - BeLike " *CmdletsToExport *wildcard*"
251+ $matchingViolations [0 ].Message | Should - BeLike " *FunctionsToExport *wildcard*"
252252 }
253253
254- It " Should flag wildcard in array of exports " {
255- $manifestPath = Join-Path $tempPath " WildcardArray .psd1"
254+ It " Should flag wildcard in CmdletsToExport " {
255+ $manifestPath = Join-Path $tempPath " WildcardCmdlets .psd1"
256256 $manifestContent = @'
257257@{
258258 ModuleVersion = '1.0.0'
259259 GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
260- AliasesToExport = @('Get-Foo', '*', 'Set-Bar')
260+ CmdletsToExport = '*'
261261}
262262'@
263263 Set-Content - Path $manifestPath - Value $manifestContent
264264 $violations = Invoke-ScriptAnalyzer - Path $manifestPath - Settings $settings
265265 $matchingViolations = $violations | Where-Object { $_.RuleName -eq $violationName }
266266 $matchingViolations.Count | Should - BeGreaterThan 0
267- $matchingViolations [0 ].Message | Should - BeLike " *AliasesToExport *wildcard*"
267+ $matchingViolations [0 ].Message | Should - BeLike " *CmdletsToExport *wildcard*"
268268 }
269269
270270 It " Should NOT flag explicit list of exports" {
@@ -336,6 +336,73 @@ enum MyEnum {
336336 $scriptModuleViolations | Should - BeNullOrEmpty
337337 }
338338
339+ It " Should flag .ps1 file in ScriptsToProcess" {
340+ $manifestPath = Join-Path $tempPath " ScriptsToProcess.psd1"
341+ $manifestContent = @'
342+ @{
343+ ModuleVersion = '1.0.0'
344+ GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
345+ ScriptsToProcess = @('Init.ps1', 'Setup.ps1')
346+ }
347+ '@
348+ Set-Content - Path $manifestPath - Value $manifestContent
349+ $violations = Invoke-ScriptAnalyzer - Path $manifestPath - Settings $settings
350+ $matchingViolations = $violations | Where-Object { $_.RuleName -eq $violationName }
351+ $matchingViolations.Count | Should - BeGreaterThan 0
352+ $matchingViolations [0 ].Message | Should - BeLike " *ScriptsToProcess*Init.ps1*"
353+ }
354+
355+ It " Should use different error message for ScriptsToProcess" {
356+ $manifestPath = Join-Path $tempPath " ScriptsToProcessMessage.psd1"
357+ $manifestContent = @'
358+ @{
359+ ModuleVersion = '1.0.0'
360+ GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
361+ ScriptsToProcess = 'Init.ps1'
362+ }
363+ '@
364+ Set-Content - Path $manifestPath - Value $manifestContent
365+ $violations = Invoke-ScriptAnalyzer - Path $manifestPath - Settings $settings
366+ $matchingViolations = $violations | Where-Object { $_.RuleName -eq $violationName }
367+ $matchingViolations.Count | Should - Be 1
368+ # ScriptsToProcess should have a specific message about caller's session state
369+ $matchingViolations [0 ].Message | Should - BeLike " *caller*session state*"
370+ $matchingViolations [0 ].Message | Should - BeLike " *Init.ps1*"
371+ }
372+
373+ It " Should flag single-item array in ScriptsToProcess" {
374+ $manifestPath = Join-Path $tempPath " ScriptsToProcessArray.psd1"
375+ $manifestContent = @'
376+ @{
377+ ModuleVersion = '1.0.0'
378+ GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
379+ ScriptsToProcess = @('Init.ps1')
380+ }
381+ '@
382+ Set-Content - Path $manifestPath - Value $manifestContent
383+ $violations = Invoke-ScriptAnalyzer - Path $manifestPath - Settings $settings
384+ $matchingViolations = $violations | Where-Object { $_.RuleName -eq $violationName }
385+ $matchingViolations.Count | Should - Be 1
386+ $matchingViolations [0 ].Message | Should - BeLike " *ScriptsToProcess*Init.ps1*"
387+ }
388+
389+ It " Should NOT flag .psm1 files in ScriptsToProcess" {
390+ $manifestPath = Join-Path $tempPath " ScriptsToProcessPsm1.psd1"
391+ $manifestContent = @'
392+ @{
393+ ModuleVersion = '1.0.0'
394+ GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
395+ ScriptsToProcess = @('Init.psm1')
396+ }
397+ '@
398+ Set-Content - Path $manifestPath - Value $manifestContent
399+ $violations = Invoke-ScriptAnalyzer - Path $manifestPath - Settings $settings
400+ $scriptViolations = $violations | Where-Object {
401+ $_.RuleName -eq $violationName -and $_.Message -like " *ScriptsToProcess*"
402+ }
403+ $scriptViolations | Should - BeNullOrEmpty
404+ }
405+
339406 It " Should flag both wildcard and .ps1 issues in same manifest" {
340407 $manifestPath = Join-Path $tempPath " MultipleIssues.psd1"
341408 $manifestContent = @'
@@ -353,6 +420,33 @@ enum MyEnum {
353420 # Should have at least 3 violations: RootModule .ps1, FunctionsToExport *, CmdletsToExport *
354421 $matchingViolations.Count | Should - BeGreaterOrEqual 3
355422 }
423+
424+ It " Should flag ScriptsToProcess and RootModule with different messages" {
425+ $manifestPath = Join-Path $tempPath " MixedScriptFields.psd1"
426+ $manifestContent = @'
427+ @{
428+ ModuleVersion = '1.0.0'
429+ GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
430+ RootModule = 'MyModule.ps1'
431+ ScriptsToProcess = @('Init.ps1')
432+ }
433+ '@
434+ Set-Content - Path $manifestPath - Value $manifestContent
435+ $violations = Invoke-ScriptAnalyzer - Path $manifestPath - Settings $settings
436+ $matchingViolations = $violations | Where-Object { $_.RuleName -eq $violationName }
437+ $matchingViolations.Count | Should - Be 2
438+
439+ # Check that we have both types of messages
440+ $scriptsToProcessMsg = $matchingViolations | Where-Object { $_.Message -like " *caller*session state*" }
441+ $rootModuleMsg = $matchingViolations | Where-Object { $_.Message -like " *RootModule*" -and $_.Message -notlike " *caller*session state*" }
442+
443+ $scriptsToProcessMsg.Count | Should - Be 1
444+ $rootModuleMsg.Count | Should - Be 1
445+
446+ # Verify the specific field names are mentioned
447+ $scriptsToProcessMsg [0 ].Message | Should - BeLike " *Init.ps1*"
448+ $rootModuleMsg [0 ].Message | Should - BeLike " *MyModule.ps1*"
449+ }
356450 }
357451
358452 Context " Rule severity" {
@@ -628,6 +722,7 @@ class MyClass {
628722 $scriptPath = Join-Path $tempPath " SignedWithDotSource.ps1"
629723 $scriptContent = @'
630724. .\Helper.ps1
725+ . .\U tility.ps1
631726
632727# SIG # Begin signature block
633728# MIIFFAYJKoZIhvcNAQcCoIIFBTCCBQECAQExCzAJ...
0 commit comments