From 6def4a3180fe03981ba64c6d8db28fed3bb39c0c Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Wed, 2 Nov 2022 07:44:46 +1000 Subject: Fix up sanity problems --- lib/ansible/executor/powershell/async_wrapper.ps1 | 10 ++--- .../powershell/Ansible.ModuleUtils.Backup.psm1 | 2 +- .../powershell/Ansible.ModuleUtils.Legacy.psm1 | 10 ++--- .../win_script/files/test_script_with_args.ps1 | 2 +- .../win_script/files/test_script_with_errors.ps1 | 2 +- .../windows-minimal/library/win_ping_set_attr.ps1 | 8 ++-- .../library/win_ping_strict_mode_error.ps1 | 8 ++-- .../library/win_ping_syntax_error.ps1 | 8 ++-- .../windows-minimal/library/win_ping_throw.ps1 | 8 ++-- .../library/win_ping_throw_string.ps1 | 8 ++-- .../_util/controller/sanity/pslint/settings.psd1 | 50 +++++++++++----------- 11 files changed, 58 insertions(+), 58 deletions(-) diff --git a/lib/ansible/executor/powershell/async_wrapper.ps1 b/lib/ansible/executor/powershell/async_wrapper.ps1 index 0cd640fd16..dd5a9becc5 100644 --- a/lib/ansible/executor/powershell/async_wrapper.ps1 +++ b/lib/ansible/executor/powershell/async_wrapper.ps1 @@ -135,11 +135,11 @@ try { # populate initial results before we send the async data to avoid result race $result = @{ - started = 1; - finished = 0; - results_file = $results_path; - ansible_job_id = $local_jid; - _ansible_suppress_tmpdir_delete = $true; + started = 1 + finished = 0 + results_file = $results_path + ansible_job_id = $local_jid + _ansible_suppress_tmpdir_delete = $true ansible_async_watchdog_pid = $watchdog_pid } diff --git a/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Backup.psm1 b/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Backup.psm1 index ca4f5ba5b0..c2b80b011b 100644 --- a/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Backup.psm1 +++ b/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Backup.psm1 @@ -18,7 +18,7 @@ Function Backup-File { Process { $backup_path = $null if (Test-Path -LiteralPath $path -PathType Leaf) { - $backup_path = "$path.$pid." + [DateTime]::Now.ToString("yyyyMMdd-HHmmss") + ".bak"; + $backup_path = "$path.$pid." + [DateTime]::Now.ToString("yyyyMMdd-HHmmss") + ".bak" Try { Copy-Item -LiteralPath $path -Destination $backup_path } diff --git a/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 b/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 index f0cb440f68..4aea98b24f 100644 --- a/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 +++ b/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 @@ -354,16 +354,16 @@ Function Get-FileChecksum($path, $algorithm = 'sha1') { $hash = $raw_hash.Hash.ToLower() } Else { - $fp = [System.IO.File]::Open($path, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite); - $hash = [System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower(); - $fp.Dispose(); + $fp = [System.IO.File]::Open($path, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite) + $hash = [System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower() + $fp.Dispose() } } ElseIf (Test-Path -LiteralPath $path -PathType Container) { - $hash = "3"; + $hash = "3" } Else { - $hash = "1"; + $hash = "1" } return $hash } diff --git a/test/integration/targets/win_script/files/test_script_with_args.ps1 b/test/integration/targets/win_script/files/test_script_with_args.ps1 index 01bb37f5d7..669c641008 100644 --- a/test/integration/targets/win_script/files/test_script_with_args.ps1 +++ b/test/integration/targets/win_script/files/test_script_with_args.ps1 @@ -2,5 +2,5 @@ # passed to the script. foreach ($i in $args) { - Write-Host $i; + Write-Host $i } diff --git a/test/integration/targets/win_script/files/test_script_with_errors.ps1 b/test/integration/targets/win_script/files/test_script_with_errors.ps1 index 56f9773548..bdf7ee481f 100644 --- a/test/integration/targets/win_script/files/test_script_with_errors.ps1 +++ b/test/integration/targets/win_script/files/test_script_with_errors.ps1 @@ -2,7 +2,7 @@ trap { Write-Error -ErrorRecord $_ - exit 1; + exit 1 } throw "Oh noes I has an error" diff --git a/test/integration/targets/windows-minimal/library/win_ping_set_attr.ps1 b/test/integration/targets/windows-minimal/library/win_ping_set_attr.ps1 index f17049643b..d23bbc74a8 100644 --- a/test/integration/targets/windows-minimal/library/win_ping_set_attr.ps1 +++ b/test/integration/targets/windows-minimal/library/win_ping_set_attr.ps1 @@ -16,16 +16,16 @@ # POWERSHELL_COMMON -$params = Parse-Args $args $true; +$params = Parse-Args $args $true -$data = Get-Attr $params "data" "pong"; +$data = Get-Attr $params "data" "pong" $result = @{ changed = $false ping = "pong" -}; +} # Test that Set-Attr will replace an existing attribute. Set-Attr $result "ping" $data -Exit-Json $result; +Exit-Json $result diff --git a/test/integration/targets/windows-minimal/library/win_ping_strict_mode_error.ps1 b/test/integration/targets/windows-minimal/library/win_ping_strict_mode_error.ps1 index 508174afcc..09400d08b4 100644 --- a/test/integration/targets/windows-minimal/library/win_ping_strict_mode_error.ps1 +++ b/test/integration/targets/windows-minimal/library/win_ping_strict_mode_error.ps1 @@ -16,15 +16,15 @@ # POWERSHELL_COMMON -$params = Parse-Args $args $true; +$params = Parse-Args $args $true $params.thisPropertyDoesNotExist -$data = Get-Attr $params "data" "pong"; +$data = Get-Attr $params "data" "pong" $result = @{ changed = $false ping = $data -}; +} -Exit-Json $result; +Exit-Json $result diff --git a/test/integration/targets/windows-minimal/library/win_ping_syntax_error.ps1 b/test/integration/targets/windows-minimal/library/win_ping_syntax_error.ps1 index d4c9f07ad5..6932d5380b 100644 --- a/test/integration/targets/windows-minimal/library/win_ping_syntax_error.ps1 +++ b/test/integration/targets/windows-minimal/library/win_ping_syntax_error.ps1 @@ -18,13 +18,13 @@ $blah = 'I can't quote my strings correctly.' -$params = Parse-Args $args $true; +$params = Parse-Args $args $true -$data = Get-Attr $params "data" "pong"; +$data = Get-Attr $params "data" "pong" $result = @{ changed = $false ping = $data -}; +} -Exit-Json $result; +Exit-Json $result diff --git a/test/integration/targets/windows-minimal/library/win_ping_throw.ps1 b/test/integration/targets/windows-minimal/library/win_ping_throw.ps1 index 7306f4d280..2fba2092d7 100644 --- a/test/integration/targets/windows-minimal/library/win_ping_throw.ps1 +++ b/test/integration/targets/windows-minimal/library/win_ping_throw.ps1 @@ -18,13 +18,13 @@ throw -$params = Parse-Args $args $true; +$params = Parse-Args $args $true -$data = Get-Attr $params "data" "pong"; +$data = Get-Attr $params "data" "pong" $result = @{ changed = $false ping = $data -}; +} -Exit-Json $result; +Exit-Json $result diff --git a/test/integration/targets/windows-minimal/library/win_ping_throw_string.ps1 b/test/integration/targets/windows-minimal/library/win_ping_throw_string.ps1 index 09e3b7cb45..62de8263dd 100644 --- a/test/integration/targets/windows-minimal/library/win_ping_throw_string.ps1 +++ b/test/integration/targets/windows-minimal/library/win_ping_throw_string.ps1 @@ -18,13 +18,13 @@ throw "no ping for you" -$params = Parse-Args $args $true; +$params = Parse-Args $args $true -$data = Get-Attr $params "data" "pong"; +$data = Get-Attr $params "data" "pong" $result = @{ changed = $false ping = $data -}; +} -Exit-Json $result; +Exit-Json $result diff --git a/test/lib/ansible_test/_util/controller/sanity/pslint/settings.psd1 b/test/lib/ansible_test/_util/controller/sanity/pslint/settings.psd1 index 41be367404..7beb38c1d8 100644 --- a/test/lib/ansible_test/_util/controller/sanity/pslint/settings.psd1 +++ b/test/lib/ansible_test/_util/controller/sanity/pslint/settings.psd1 @@ -1,40 +1,40 @@ @{ - Rules = @{ - PSAvoidLongLines = @{ - Enable = $true + Rules = @{ + PSAvoidLongLines = @{ + Enable = $true MaximumLineLength = 160 } PSAvoidSemicolonsAsLineTerminators = @{ Enable = $true } - PSPlaceOpenBrace = @{ - Enable = $true - OnSameLine = $true + PSPlaceOpenBrace = @{ + Enable = $true + OnSameLine = $true IgnoreOneLineBlock = $true - NewLineAfter = $true + NewLineAfter = $true } - PSPlaceCloseBrace = @{ - Enable = $true + PSPlaceCloseBrace = @{ + Enable = $true IgnoreOneLineBlock = $true - NewLineAfter = $true - NoEmptyLineBefore = $false + NewLineAfter = $true + NoEmptyLineBefore = $false } - PSUseConsistentIndentation = @{ - Enable = $true - IndentationSize = 4 + PSUseConsistentIndentation = @{ + Enable = $true + IndentationSize = 4 PipelineIndentation = 'IncreaseIndentationForFirstPipeline' - Kind = 'space' + Kind = 'space' } - PSUseConsistentWhitespace = @{ - Enable = $true - CheckInnerBrace = $true - CheckOpenBrace = $true - CheckOpenParen = $true - CheckOperator = $true - CheckPipe = $true - CheckPipeForRedundantWhitespace = $false - CheckSeparator = $true - CheckParameter = $false + PSUseConsistentWhitespace = @{ + Enable = $true + CheckInnerBrace = $true + CheckOpenBrace = $true + CheckOpenParen = $true + CheckOperator = $true + CheckPipe = $true + CheckPipeForRedundantWhitespace = $false + CheckSeparator = $true + CheckParameter = $false IgnoreAssignmentOperatorInsideHashTable = $false } } -- cgit v1.2.1