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 authored and Dongbo Wang committed 2017-07-21 21:03:49 -07:00
1 parent e23d2e53d5
commit ffd39b2853
99 files changed
+694 -694

No files matched your search

@@ -29,7 +29,7 @@
foreach ($cmdlet in $cmdletList)
{
# If the cmdlet is not preset in CoreCLR, skip it.
$skipTest = (Get-Command $cmdlet.TopicTitle -ea SilentlyContinue) -eq $null
$skipTest = $null -eq (Get-Command $cmdlet.TopicTitle -ea SilentlyContinue)
# TopicTitle - is the cmdlet name in the csv file
# HelpURI - is the expected help URI in the csv file
@@ -265,11 +265,11 @@ function ValidateSaveHelp
[string]$path
)
$compressedFile = GetFiles -fileType "*$extension" -path $path | foreach {Split-Path $_ -Leaf}
$compressedFile = GetFiles -fileType "*$extension" -path $path | ForEach-Object {Split-Path $_ -Leaf}
$expectedCompressedFile = $testCases[$moduleName].CompressedFiles
$expectedCompressedFile | Should Be $compressedFile
$helpInfoFile = GetFiles -fileType "*HelpInfo.xml" -path $path | foreach {Split-Path $_ -Leaf}
$helpInfoFile = GetFiles -fileType "*HelpInfo.xml" -path $path | ForEach-Object {Split-Path $_ -Leaf}
$expectedHelpInfoFile = $testCases[$moduleName].HelpInfoFiles
$expectedHelpInfoFile | Should Be $helpInfoFile
}