From 419b55c318a5fe6ed66ab5673ff8dbaa523b213f Mon Sep 17 00:00:00 2001 From: freddydk Date: Mon, 7 Aug 2023 22:52:13 +0200 Subject: [PATCH] Scriptanalyzer fixes --- Actions/AL-Go-Helper.ps1 | 16 ++++++++-------- .../CalculateArtifactNames.ps1 | 10 +++++----- .../DownloadProjectDependencies.Action.ps1 | 4 ++-- Actions/ReadSecrets/ReadSecrets.ps1 | 2 +- Actions/VerifyPRChanges/VerifyPRChanges.ps1 | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Actions/AL-Go-Helper.ps1 b/Actions/AL-Go-Helper.ps1 index bee389962..44428d838 100644 --- a/Actions/AL-Go-Helper.ps1 +++ b/Actions/AL-Go-Helper.ps1 @@ -420,7 +420,7 @@ function ReadSettings { [string] $repoSettingsVariableValue = "$ENV:ALGoRepoSettings" ) - function GetSettingsObject { + function GetSettingsObject { Param( [string] $path ) @@ -966,10 +966,10 @@ function AnalyzeRepo { $settings.appDependencyProbingPaths = @($settings.appDependencyProbingPaths | ForEach-Object { if ($_.GetType().Name -eq "PSCustomObject") { $_ - } - else { + } + else { New-Object -Type PSObject -Property $_ - } + } }) $settings.appDependencyProbingPaths | ForEach-Object { $dependency = $_ @@ -1044,7 +1044,7 @@ function AnalyzeRepo { "appFolders", "testFolders" | ForEach-Object { $propertyName = $_ Write-Host "Adding folders from $depProject to $_" - $found = $true + $found = $false $depSettings."$propertyName" | ForEach-Object { $folder = (Resolve-Path -Path (Join-Path $baseFolder "$depProject/$_") -Relative).ToLowerInvariant() if (!$settings."$propertyName".Contains($folder)) { @@ -1568,10 +1568,10 @@ function CreateDevEnv { $repo.appDependencyProbingPaths = @($repo.appDependencyProbingPaths | ForEach-Object { if ($_.GetType().Name -eq "PSCustomObject") { $_ - } - else { + } + else { New-Object -Type PSObject -Property $_ - } + } }) Get-Dependencies -probingPathsJson $repo.appDependencyProbingPaths -saveToPath $dependenciesFolder -api_url 'https://api.github.com' | ForEach-Object { if ($_.startswith('(')) { diff --git a/Actions/CalculateArtifactNames/CalculateArtifactNames.ps1 b/Actions/CalculateArtifactNames/CalculateArtifactNames.ps1 index a296cbc0a..ea252188b 100644 --- a/Actions/CalculateArtifactNames/CalculateArtifactNames.ps1 +++ b/Actions/CalculateArtifactNames/CalculateArtifactNames.ps1 @@ -22,21 +22,21 @@ $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-S try { $settings = $env:Settings | ConvertFrom-Json - if ($project -eq ".") { - $project = $settings.repoName + if ($project -eq ".") { + $project = $settings.repoName } $branchName = $branchName.Replace('\', '_').Replace('/', '_') $projectName = $project.Replace('\', '_').Replace('/', '_') # If the buildmode is default, then we don't want to add it to the artifact name - if ($buildMode -eq 'Default') { - $buildMode = '' + if ($buildMode -eq 'Default') { + $buildMode = '' } Set-OutputVariable -name "BuildMode" -value $buildMode if ($suffix) { - # Add the date to the suffix + # Add the date to the suffix $suffix = "$suffix-$([DateTime]::UtcNow.ToString('yyyyMMdd'))" } else { diff --git a/Actions/DownloadProjectDependencies/DownloadProjectDependencies.Action.ps1 b/Actions/DownloadProjectDependencies/DownloadProjectDependencies.Action.ps1 index 8865f431c..28425ae43 100644 --- a/Actions/DownloadProjectDependencies/DownloadProjectDependencies.Action.ps1 +++ b/Actions/DownloadProjectDependencies/DownloadProjectDependencies.Action.ps1 @@ -107,10 +107,10 @@ try { $downloadedDependencies | ForEach-Object { # naming convention: app, (testapp) if ($_.startswith('(')) { - $DownloadedTestApps += $_ + $DownloadedTestApps += $_ } else { - $DownloadedApps += $_ + $DownloadedApps += $_ } } diff --git a/Actions/ReadSecrets/ReadSecrets.ps1 b/Actions/ReadSecrets/ReadSecrets.ps1 index 74380caf4..ef9e0cbb6 100644 --- a/Actions/ReadSecrets/ReadSecrets.ps1 +++ b/Actions/ReadSecrets/ReadSecrets.ps1 @@ -64,7 +64,7 @@ try { $settings.appDependencyProbingPaths | ForEach-Object { if ($_.PsObject.Properties.name -eq "AuthTokenSecret") { $secretsCollection += $_.authTokenSecret - } + } } } diff --git a/Actions/VerifyPRChanges/VerifyPRChanges.ps1 b/Actions/VerifyPRChanges/VerifyPRChanges.ps1 index 6207a9fb8..5de918021 100644 --- a/Actions/VerifyPRChanges/VerifyPRChanges.ps1 +++ b/Actions/VerifyPRChanges/VerifyPRChanges.ps1 @@ -23,7 +23,7 @@ function ValidateFiles if (($extension -in $disallowedExtensions) -or ($name -in $disallowedFiles) -or $filename.StartsWith(".github/")) { throw "Pull Request containing changes to scripts, workflows or CODEOWNERS are not allowed from forks." } - } + } } function ValidatePullRequest @@ -79,11 +79,11 @@ $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-S # IMPORTANT: All actions needs a try/catch here and not only in the yaml file, else they can silently fail try { - $headers = @{ + $headers = @{ "Authorization" = "token $token" "Accept" = "application/vnd.github.baptiste-preview+json" } - + ValidatePullRequest -PullRequestRepository $prBaseRepository -PullRequestId $pullRequestId -Headers $headers ValidatePullRequestFiles -PullRequestRepository $prBaseRepository -PullRequestId $pullRequestId -Headers $headers }