better null comparison (#10915)

This commit is contained in:
William Cheng
2021-11-21 23:03:25 +08:00
committed by GitHub
parent 37a4429024
commit c244c23053
8 changed files with 13 additions and 13 deletions

View File

@@ -178,7 +178,7 @@ function Set-PSConfiguration {
$Script:Configuration['DefaultHeaders'] = $DefaultHeaders
}
If ($Proxy -ne $null) {
If ($null -ne $Proxy) {
If ($Proxy.GetType().FullName -ne "System.Net.SystemWebProxy" -and $Proxy.GetType().FullName -ne "System.Net.WebRequest+WebProxyWrapperOpaque") {
throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must be System.Net.SystemWebProxy or System.Net.WebRequest+WebProxyWrapperOpaque."
}

View File

@@ -59,11 +59,11 @@ function Initialize-PSPet {
'Creating PSCustomObject: PSPetstore => PSPet' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug
if ($Name -eq $null) {
if ($null -eq $Name) {
throw "invalid value for 'Name', 'Name' cannot be null."
}
if ($PhotoUrls -eq $null) {
if ($null -eq $PhotoUrls) {
throw "invalid value for 'PhotoUrls', 'PhotoUrls' cannot be null."
}

View File

@@ -131,7 +131,7 @@ function Invoke-PSApiClient {
}
if ($SkipCertificateCheck -eq $true) {
if ($Configuration["Proxy"] -eq $null) {
if ($null -eq $Configuration["Proxy"]) {
# skip certification check, no proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
@@ -153,7 +153,7 @@ function Invoke-PSApiClient {
-ProxyUseDefaultCredentials
}
} else {
if ($Configuration["Proxy"] -eq $null) {
if ($null -eq $Configuration["Proxy"]) {
# perform certification check, no proxy
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
@@ -228,7 +228,7 @@ function DeserializeResponse {
[string[]]$ContentTypes
)
If ($ContentTypes -eq $null) {
If ($null -eq $ContentTypes) {
$ContentTypes = [string[]]@()
}