refactor: use -not for string parameter null/empty checks (#870 follow-up) - #916
Open
pavankadabala-png wants to merge 7 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #913, per @FH-Inway's request to apply the [string]::IsNullOrEmpty -> -not simplification (suggested by @FriedrichWeinmann in #870) to other string-parameter checks across the module.
For a [string] parameter, [string]::IsNullOrEmpty($x) is equivalent to -not $x, so this replaces the more verbose form. Changes span 7 files. Public cmdlets: Invoke-D365AzCopyTransfer ($FileName, 2x), Import-D365Bacpac ($DiagnosticFile, $ModelFile), New-D365Bacpac ($DiagnosticFile), Repair-D365BacpacModelFile ($OutputPath + 3 path params), Get-D365TfsWorkspace ($TfsUri). Internal helpers: Invoke-Process ($LogPath), Test-PathExists ($item, iterating [string[]] $Path).
Scope was limited to operands that are declared [string]/[string[]] parameters, where -not is exactly equivalent. I intentionally left the sites where the operand is an object or external-command output (Get-MpComputerStatus $defenderOptions, the tf.exe $res results, $res.FlightingServiceCatalogID), since -not is not equivalent there (matching the caveat from #913). Only if-condition expressions changed; no parameter or help changes. (The web editor also normalized a missing end-of-file newline in each touched file.)
Refs #870, #913