Skip to content

Commit 4d5720c

Browse files
🪲 [Fix]: Fix boolean evaluations for input parameters (#28)
## Description This pull request includes several changes aimed at improving the handling of boolean values in the configuration scripts. The changes primarily focus on replacing null checks with `IsNullOrEmpty` method calls to simplify and standardize the code. Improvements to boolean value handling: * `scripts/init.ps1`: * Replaced null checks with `IsNullOrEmpty` method calls for boolean inputs to capture correct state of the value. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [ ] 🩹 [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 174efc7 commit 4d5720c

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

scripts/init.ps1

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ LogGroup 'Init - Load configuration - Action overrides' {
9595
ScriptBlock = $inputs.Run_ScriptBlock
9696
Container = $inputs.Run_Container
9797
TestExtension = $inputs.Run_TestExtension
98-
Exit = $null -ne $inputs.Run_Exit ? $inputs.Run_Exit -eq 'true' : $null
99-
Throw = $null -ne $inputs.Run_Throw ? $inputs.Run_Throw -eq 'true' : $null
100-
SkipRun = $null -ne $inputs.Run_SkipRun ? $inputs.Run_SkipRun -eq 'true' : $null
98+
Exit = [string]::IsNullOrEmpty($inputs.Run_Exit) ? $null : $inputs.Run_Exit -eq 'true'
99+
Throw = [string]::IsNullOrEmpty($inputs.Run_Throw) ? $null : $inputs.Run_Throw -eq 'true'
100+
SkipRun = [string]::IsNullOrEmpty($inputs.Run_SkipRun) ? $null : $inputs.Run_SkipRun -eq 'true'
101101
SkipRemainingOnFailure = $inputs.Run_SkipRemainingOnFailure
102102
}
103103
Filter = @{
@@ -108,19 +108,21 @@ LogGroup 'Init - Load configuration - Action overrides' {
108108
FullName = $inputs.Filter_FullName
109109
}
110110
CodeCoverage = @{
111-
Enabled = $null -ne $inputs.CodeCoverage_Enabled ? $inputs.CodeCoverage_Enabled -eq 'true' : $null
111+
Enabled = [string]::IsNullOrEmpty($inputs.CodeCoverage_Enabled) ? $null : $inputs.CodeCoverage_Enabled -eq 'true'
112112
OutputFormat = $inputs.CodeCoverage_OutputFormat
113113
OutputPath = $inputs.CodeCoverage_OutputPath
114114
OutputEncoding = $inputs.CodeCoverage_OutputEncoding
115115
Path = $inputs.CodeCoverage_Path
116-
ExcludeTests = $null -ne $inputs.CodeCoverage_ExcludeTests ? $inputs.CodeCoverage_ExcludeTests -eq 'true' : $null
117-
RecursePaths = $null -ne $inputs.CodeCoverage_RecursePaths ? $inputs.CodeCoverage_RecursePaths -eq 'true' : $null
116+
ExcludeTests = [string]::IsNullOrEmpty($inputs.CodeCoverage_ExcludeTests) ? $null : $inputs.CodeCoverage_ExcludeTests -eq 'true'
117+
RecursePaths = [string]::IsNullOrEmpty($inputs.CodeCoverage_RecursePaths) ? $null : $inputs.CodeCoverage_RecursePaths -eq 'true'
118118
CoveragePercentTarget = [decimal]$inputs.CodeCoverage_CoveragePercentTarget
119-
UseBreakpoints = $null -ne $inputs.CodeCoverage_UseBreakpoints ? $inputs.CodeCoverage_UseBreakpoints -eq 'true' : $null
120-
SingleHitBreakpoints = $null -ne $inputs.CodeCoverage_SingleHitBreakpoints ? $inputs.CodeCoverage_SingleHitBreakpoints -eq 'true' : $null
119+
UseBreakpoints = [string]::IsNullOrEmpty($inputs.CodeCoverage_UseBreakpoints) ?
120+
$null : $inputs.CodeCoverage_UseBreakpoints -eq 'true'
121+
SingleHitBreakpoints = [string]::IsNullOrEmpty($inputs.CodeCoverage_SingleHitBreakpoints) ?
122+
$null : $inputs.CodeCoverage_SingleHitBreakpoints -eq 'true'
121123
}
122124
TestResult = @{
123-
Enabled = $null -ne $inputs.TestResult_Enabled ? $inputs.TestResult_Enabled -eq 'true' : $null
125+
Enabled = [string]::IsNullOrEmpty($inputs.TestResult_Enabled) ? $null : $inputs.TestResult_Enabled -eq 'true'
124126
OutputFormat = $inputs.TestResult_OutputFormat
125127
OutputPath = $inputs.TestResult_OutputPath
126128
OutputEncoding = $inputs.TestResult_OutputEncoding
@@ -130,11 +132,13 @@ LogGroup 'Init - Load configuration - Action overrides' {
130132
ErrorAction = $inputs.Should_ErrorAction
131133
}
132134
Debug = @{
133-
ShowFullErrors = $null -ne $inputs.Debug_ShowFullErrors ? $inputs.Debug_ShowFullErrors -eq 'true' : $null
134-
WriteDebugMessages = $null -ne $inputs.Debug_WriteDebugMessages ? $inputs.Debug_WriteDebugMessages -eq 'true' : $null
135+
ShowFullErrors = [string]::IsNullOrEmpty($inputs.Debug_ShowFullErrors) ? $null : $inputs.Debug_ShowFullErrors -eq 'true'
136+
WriteDebugMessages = [string]::IsNullOrEmpty($inputs.Debug_WriteDebugMessages) ? $null : $inputs.Debug_WriteDebugMessages -eq 'true'
135137
WriteDebugMessagesFrom = $inputs.Debug_WriteDebugMessagesFrom
136-
ShowNavigationMarkers = $null -ne $inputs.Debug_ShowNavigationMarkers ? $inputs.Debug_ShowNavigationMarkers -eq 'true' : $null
137-
ReturnRawResultObject = $null -ne $inputs.Debug_ReturnRawResultObject ? $inputs.Debug_ReturnRawResultObject -eq 'true' : $null
138+
ShowNavigationMarkers = [string]::IsNullOrEmpty($inputs.Debug_ShowNavigationMarkers) ?
139+
$null : $inputs.Debug_ShowNavigationMarkers -eq 'true'
140+
ReturnRawResultObject = [string]::IsNullOrEmpty($inputs.Debug_ReturnRawResultObject) ?
141+
$null : $inputs.Debug_ReturnRawResultObject -eq 'true'
138142
}
139143
Output = @{
140144
CIFormat = $inputs.Output_CIFormat
@@ -144,10 +148,10 @@ LogGroup 'Init - Load configuration - Action overrides' {
144148
RenderMode = $inputs.Output_RenderMode
145149
}
146150
TestDrive = @{
147-
Enabled = $null -ne $inputs.TestDrive_Enabled ? $inputs.TestDrive_Enabled -eq 'true' : $null
151+
Enabled = [string]::IsNullOrEmpty($inputs.TestDrive_Enabled) ? $null : $inputs.TestDrive_Enabled -eq 'true'
148152
}
149153
TestRegistry = @{
150-
Enabled = $null -ne $inputs.TestRegistry_Enabled ? $inputs.TestRegistry_Enabled -eq 'true' : $null
154+
Enabled = [string]::IsNullOrEmpty($inputs.TestRegistry_Enabled) ? $null : $inputs.TestRegistry_Enabled -eq 'true'
151155
}
152156
}
153157

0 commit comments

Comments
 (0)