PSScriptAnalyzer fixes by category (#4261)

- Fix PSScriptAnalyzer warnings of type PSAvoidUsingCmdletAliases for 'ForEach-Object' (alias is '%' or 'foreach')
- Fix PSScriptAnalyzer warnings of type PSAvoidUsingCmdletAliases for 'Where-Object' (alias is '?' or 'where')
- Fix PSScriptAnalyzer warnings of type PSAvoidUsingCmdletAliases for 'Select-Object' (alias is 'select')
- Fix PSScriptAnalyzer warnings of type PSPossibleIncorrectComparisonWithNull. Essentially, $null has to be on the left-hand side when using it for comparison.
- A Test in ParameterBinding.Tests.ps1 needed adapting as this test used to rely on the wrong null comparison
- Replace a subset of tests of kind '($object -eq $null) | Should Be $true' with '$object | Should Be $null'
This commit is contained in:
bergmeister
2017-07-21 21:03:49 -07:00
committed by Dongbo Wang
parent e23d2e53d5
commit ffd39b2853
99 changed files with 694 additions and 694 deletions
@@ -1,7 +1,7 @@
$script1 = @'
'aaa'.ToString() > $null
'aa' > $null
"a" 2> $null | % { $_ }
"a" 2> $null | ForEach-Object { $_ }
'bb' > $null
'bb'.ToSTring() > $null
'bbb'
@@ -15,7 +15,7 @@ $script2 = @'
Describe "Breakpoints when set should be hit" -tag "CI" {
BeforeAll {
$path = setup -pass -f TestScript_1.ps1 -content $script1
$bps = 1..6 | %{ set-psbreakpoint -script $path -line $_ -Action { continue } }
$bps = 1..6 | ForEach-Object { set-psbreakpoint -script $path -line $_ -Action { continue } }
}
AfterAll {
$bps | Remove-PSBreakPoint
@@ -58,8 +58,8 @@ Describe "It should be possible to reset runspace debugging" -tag "Feature" {
$rs.ResetRunspaceState()
}
AfterAll {
if ( $ps -ne $null ) { $ps.Dispose() }
if ( $ss -ne $null ) { $rs.Dispose() }
if ( $null -ne $ps ) { $ps.Dispose() }
if ( $null -ne $ss ) { $rs.Dispose() }
}
It "2 breakpoints should have been set" {
$breakpoints.Count | Should be 2