Skip to content

Commit 109306f

Browse files
committedMar 3, 2025
Refactor null checks for improved readability
Updated conditional checks in `install.ps1` to use `$null -ne variable` format. This change enhances code clarity and maintainability while preserving existing functionality. The modifications are applied consistently across multiple statements.
1 parent 1cbf0d6 commit 109306f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
 

‎install.ps1

+9-9
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ PreparingToExpandVerboseMessage=Preparing to expand...
577577

578578
foreach ($currentFilePath in $sourcePaths)
579579
{
580-
if ($modifiedSourceDirFullName -ne $null -and $modifiedSourceDirFullName.Length -gt 0)
580+
if ($null -ne $modifiedSourceDirFullName -and $modifiedSourceDirFullName.Length -gt 0)
581581
{
582582
$index = $currentFilePath.IndexOf($modifiedSourceDirFullName, [System.StringComparison]::OrdinalIgnoreCase)
583583
$currentFilePathSubString = $currentFilePath.Substring($index, $modifiedSourceDirFullName.Length)
@@ -608,7 +608,7 @@ PreparingToExpandVerboseMessage=Preparing to expand...
608608
}
609609
}
610610

611-
if ($entryToBeUpdated -ne $null)
611+
if ($null -ne $entryToBeUpdated)
612612
{
613613
$addItemtoArchiveFileMessage = ($LocalizedData.AddItemtoArchiveFile -f $currentFilePath)
614614
$entryToBeUpdated.Delete()
@@ -856,7 +856,7 @@ PreparingToExpandVerboseMessage=Preparing to expand...
856856
if ($force)
857857
{
858858
Remove-Item -LiteralPath $currentArchiveEntryFileInfo.FullName -Force -ErrorVariable ev -Verbose:$isVerbose -Confirm:$isConfirm
859-
if ($ev -ne $null)
859+
if ($null -ne $ev)
860860
{
861861
$hasNonTerminatingError = $true
862862
}
@@ -1033,7 +1033,7 @@ PreparingToExpandVerboseMessage=Preparing to expand...
10331033
$innerException
10341034
)
10351035

1036-
if ($innerException -eq $null)
1036+
if ($null -eq $innerException)
10371037
{
10381038
$exception = New-Object System.IO.IOException $errorMessage
10391039
}
@@ -1723,7 +1723,7 @@ PreparingToExpandVerboseMessage=Preparing to expand...
17231723

17241724
foreach ($currentFilePath in $sourcePaths)
17251725
{
1726-
if ($modifiedSourceDirFullName -ne $null -and $modifiedSourceDirFullName.Length -gt 0)
1726+
if ($null -ne $modifiedSourceDirFullName -and $modifiedSourceDirFullName.Length -gt 0)
17271727
{
17281728
$index = $currentFilePath.IndexOf($modifiedSourceDirFullName, [System.StringComparison]::OrdinalIgnoreCase)
17291729
$currentFilePathSubString = $currentFilePath.Substring($index, $modifiedSourceDirFullName.Length)
@@ -1754,7 +1754,7 @@ PreparingToExpandVerboseMessage=Preparing to expand...
17541754
}
17551755
}
17561756

1757-
if ($entryToBeUpdated -ne $null)
1757+
if ($null -ne $entryToBeUpdated)
17581758
{
17591759
$addItemtoArchiveFileMessage = ($LocalizedData.AddItemtoArchiveFile -f $currentFilePath)
17601760
$entryToBeUpdated.Delete()
@@ -2002,7 +2002,7 @@ PreparingToExpandVerboseMessage=Preparing to expand...
20022002
if ($force)
20032003
{
20042004
Remove-Item -LiteralPath $currentArchiveEntryFileInfo.FullName -Force -ErrorVariable ev -Verbose:$isVerbose -Confirm:$isConfirm
2005-
if ($ev -ne $null)
2005+
if ($null -ne $ev)
20062006
{
20072007
$hasNonTerminatingError = $true
20082008
}
@@ -2179,7 +2179,7 @@ PreparingToExpandVerboseMessage=Preparing to expand...
21792179
$innerException
21802180
)
21812181

2182-
if ($innerException -eq $null)
2182+
if ($null -eq $innerException)
21832183
{
21842184
$exception = New-Object System.IO.IOException $errorMessage
21852185
}
@@ -2259,7 +2259,7 @@ PreparingToExpandVerboseMessage=Preparing to expand...
22592259
else
22602260
{
22612261
$createdItem = New-Item -Path $DestinationPath -ItemType Directory -Confirm:$isConfirm -Verbose:$isVerbose -ErrorAction Stop
2262-
if ($createdItem -ne $null -and $createdItem.PSProvider.Name -ne "FileSystem")
2262+
if ($null -ne $createdItem -and $createdItem.PSProvider.Name -ne "FileSystem")
22632263
{
22642264
Remove-Item "$DestinationPath" -Force -Recurse -ErrorAction SilentlyContinue
22652265
$errorMessage = ($LocalizedData.ExpandArchiveInValidDestinationPath -f $DestinationPath)

0 commit comments

Comments
 (0)