Skip to content

Commit

Permalink
de-lint code base: additional corrections of comparisons to $null
Browse files Browse the repository at this point in the history
* place $null first within comparisons to avoid inadvertent array slicing
  - ref: PowerShell/PSScriptAnalyzer#200 @@ https://archive.is/Qxkc0 @@ https://webcitation.org/6du3Cd5TY
  • Loading branch information
rivy committed Jan 30, 2016
1 parent 03c35fb commit 8e7606d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ function reset_aliases() {
function CMD_SET_encode_arg {
# CMD_SET_encode_arg( @ )
# encode string(s) to equivalent CMD command line interpretable version(s) as arguments for SET
if ($args -ne $null) {
if ($null -ne $args) {
$args | ForEach-Object {
$val = $_
$val = $($val -replace '\^','^^')
Expand Down
6 changes: 3 additions & 3 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function is_in_dir($dir, $check) {

# hashes
function hash_for_url($manifest, $url, $arch) {
$hashes = @(hash $manifest $arch) | where-object { $_ -ne $null };
$hashes = @(hash $manifest $arch) | where-object { $null -ne $_ };

if($hashes.length -eq 0) { return $null }

Expand Down Expand Up @@ -509,7 +509,7 @@ function shim_def($item) {
}

function create_shims($manifest, $dir, $global) {
$manifest.bin | where-object { $_ -ne $null } | foreach-object {
$manifest.bin | where-object { $null -ne $_ } | foreach-object {
$target, $name, $arg = shim_def $_
write-output "creating shim for $name"

Expand Down Expand Up @@ -541,7 +541,7 @@ function rm_shim($name, $shimdir) {
}

function rm_shims($manifest, $global) {
$manifest.bin | where-object { $_ -ne $null } | foreach-object {
$manifest.bin | where-object { $null -ne $_ } | foreach-object {
$target, $name, $null = shim_def $_
$shimdir = shimdir $global

Expand Down

0 comments on commit 8e7606d

Please sign in to comment.