From 92c97b25c3e4e00ba6aec003c458c0db5d7ed431 Mon Sep 17 00:00:00 2001 From: ili101 Date: Mon, 8 Apr 2019 13:34:31 +0300 Subject: [PATCH] Replace [void] with $null --- AddDataValidation.ps1 | 2 +- Export-Excel.ps1 | 2 +- Join-Worksheet.ps1 | 2 +- Send-SqlDataToExcel.ps1 | 2 +- SetFormat.ps1 | 2 +- __tests__/InputItemParameter.tests.ps1 | 12 ++++++------ 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/AddDataValidation.ps1 b/AddDataValidation.ps1 index 96ac0fd..65c2a5b 100644 --- a/AddDataValidation.ps1 +++ b/AddDataValidation.ps1 @@ -64,7 +64,7 @@ [String]$NoBlank ) if ($Range -is [Array]) { - [void]$PSBoundParameters.Remove("Range") + $null = $PSBoundParameters.Remove("Range") $Range | Add-ExcelDataValidationRule @PSBoundParameters } else { diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index f7f4072..46ed816 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -635,7 +635,7 @@ $ColumnIndex += $InputObject.Columns.Count - 1 if ($noHeader) {$row += $InputObject.Rows.Count -1 } else {$row += $InputObject.Rows.Count } - [void]$PSBoundParameters.Remove('InputObject') + $null = $PSBoundParameters.Remove('InputObject') $firstTimeThru = $false } #endregion diff --git a/Join-Worksheet.ps1 b/Join-Worksheet.ps1 index d9384fd..955ceab 100644 --- a/Join-Worksheet.ps1 +++ b/Join-Worksheet.ps1 @@ -198,7 +198,7 @@ #We accept a bunch of parameters work to pass on to Export-excel ( Autosize, Autofilter, boldtopRow Freeze ); if we have any of those call export-excel otherwise close the package here. $params = @{} + $PSBoundParameters 'Path', 'Clearsheet', 'NoHeader', 'FromLabel', 'LabelBlocks', 'HideSource', - 'Title', 'TitleFillPattern', 'TitleBackgroundColor', 'TitleBold', 'TitleSize' | ForEach-Object {[void]$params.Remove($_)} + 'Title', 'TitleFillPattern', 'TitleBackgroundColor', 'TitleBold', 'TitleSize' | ForEach-Object {$null = $params.Remove($_)} if ($params.Keys.Count) { if ($Title) { $params.StartRow = 2} $params.WorkSheetName = $WorkSheetName diff --git a/Send-SqlDataToExcel.ps1 b/Send-SqlDataToExcel.ps1 index 066dfd6..64fd9ac 100644 --- a/Send-SqlDataToExcel.ps1 +++ b/Send-SqlDataToExcel.ps1 @@ -130,7 +130,7 @@ } if ($PSBoundParameters.AutoFilter -and ($PSBoundParameters.TableName -or $PSBoundParameters.TableStyle)) { Write-Warning "Tables are automatically auto-filtered, -AutoFilter will be ignored" - [void]$PSBoundParameters.Remove('AutoFilter') + $null = $PSBoundParameters.Remove('AutoFilter') } #We were either given a session object or a connection string (with, optionally a MSSQLServer parameter) #If we got -MSSQLServer, create a SQL connection, if we didn't but we got -Connection create an ODBC connection diff --git a/SetFormat.ps1 b/SetFormat.ps1 index 058246c..2bd7461 100644 --- a/SetFormat.ps1 +++ b/SetFormat.ps1 @@ -110,7 +110,7 @@ ) process { if ($Range -is [Array]) { - [void]$PSBoundParameters.Remove("Range") + $null = $PSBoundParameters.Remove("Range") $Range | Set-ExcelRange @PSBoundParameters } else { diff --git a/__tests__/InputItemParameter.tests.ps1 b/__tests__/InputItemParameter.tests.ps1 index 57b0c94..34983e6 100644 --- a/__tests__/InputItemParameter.tests.ps1 +++ b/__tests__/InputItemParameter.tests.ps1 @@ -5,13 +5,13 @@ Describe "Exporting with -Inputobject" { #Read race results, and group by race name : export 1 row to get headers, leaving enough rows aboce to put in a link for each race $results = ((Get-Process) + (Get-Process -id $PID)) | Select-Object -last 10 -Property Name, cpu, pm, handles, StartTime $DataTable = [System.Data.DataTable]::new('Test') - [void]$DataTable.Columns.Add('Name') - [void]$DataTable.Columns.Add('CPU', [double]) - [void]$DataTable.Columns.Add('PM', [Long]) - [void]$DataTable.Columns.Add('Handles', [Int]) - [void]$DataTable.Columns.Add('StartTime', [DateTime]) + $null = $DataTable.Columns.Add('Name') + $null = $DataTable.Columns.Add('CPU', [double]) + $null = $DataTable.Columns.Add('PM', [Long]) + $null = $DataTable.Columns.Add('Handles', [Int]) + $null = $DataTable.Columns.Add('StartTime', [DateTime]) foreach ($r in $results) { - [void]$DataTable.Rows.Add($r.name, $r.CPU, $R.PM, $r.Handles, $r.StartTime) + $null = $DataTable.Rows.Add($r.name, $r.CPU, $R.PM, $r.Handles, $r.StartTime) } export-excel -Path $path -InputObject $results -WorksheetName Sheet1 -RangeName "Whole" export-excel -Path $path -InputObject $DataTable -WorksheetName Sheet2 -AutoNameRange