Skip to content

Commit d331cc9

Browse files
🩹 [Patch]: Test for usage of Out-Null (#54)
## Description - Test for usage of `Out-Null` - Fixes #25 ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent d08f4fe commit d331cc9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scripts/tests/PSModule/SourceCode.Tests.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ Describe 'PSModule - SourceCode tests' {
5656
$issues -join [Environment]::NewLine |
5757
Should -BeNullOrEmpty -Because "the script should not contain '-Verbose' unless it is disabled using ':`$false' qualifier after it."
5858
}
59+
60+
It "Should use '`$null = <commands>' instead of '<commands> | Out-Null'" {
61+
$issues = @('')
62+
$scriptFiles | ForEach-Object {
63+
Select-String -Path $_.FullName -Pattern 'Out-Null' -AllMatches | ForEach-Object {
64+
$issues += " - $($_.Path):L$($_.LineNumber)"
65+
}
66+
}
67+
$issues -join [Environment]::NewLine |
68+
Should -BeNullOrEmpty -Because "the script should use '`$null = <commands>' instead of '<commands> | Out-Null'"
69+
}
5970
}
6071

6172
Context 'Function/filter design' {

0 commit comments

Comments
 (0)