Skip to content

Commit fdd3af9

Browse files
🩹 [Patch]: Add test checking for use of ternary operations (#55)
## Description - Add test checking for use of ternary operations. - Fixed #29 ## 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 d331cc9 commit fdd3af9

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
@@ -67,6 +67,17 @@ Describe 'PSModule - SourceCode tests' {
6767
$issues -join [Environment]::NewLine |
6868
Should -BeNullOrEmpty -Because "the script should use '`$null = <commands>' instead of '<commands> | Out-Null'"
6969
}
70+
71+
It "Should not use ternary operations for compatability reasons" {
72+
$issues = @('')
73+
$scriptFiles | ForEach-Object {
74+
Select-String -Path $_.FullName -Pattern '(?<!\|)\s+\?' -AllMatches | ForEach-Object {
75+
$issues += " - $($_.Path):L$($_.LineNumber)"
76+
}
77+
}
78+
$issues -join [Environment]::NewLine |
79+
Should -BeNullOrEmpty -Because "the script should not use ternary operations for compatability with PS 5.1 and below"
80+
}
7081
}
7182

7283
Context 'Function/filter design' {

0 commit comments

Comments
 (0)