Skip to content

Commit

Permalink
🩹 [Patch]: Test for usage of Out-Null (#54)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
MariusStorhaug authored Apr 14, 2024
1 parent d08f4fe commit d331cc9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/tests/PSModule/SourceCode.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ Describe 'PSModule - SourceCode tests' {
$issues -join [Environment]::NewLine |
Should -BeNullOrEmpty -Because "the script should not contain '-Verbose' unless it is disabled using ':`$false' qualifier after it."
}

It "Should use '`$null = <commands>' instead of '<commands> | Out-Null'" {
$issues = @('')
$scriptFiles | ForEach-Object {
Select-String -Path $_.FullName -Pattern 'Out-Null' -AllMatches | ForEach-Object {
$issues += " - $($_.Path):L$($_.LineNumber)"
}
}
$issues -join [Environment]::NewLine |
Should -BeNullOrEmpty -Because "the script should use '`$null = <commands>' instead of '<commands> | Out-Null'"
}
}

Context 'Function/filter design' {
Expand Down

0 comments on commit d331cc9

Please sign in to comment.