mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
PowerShell
44 lines
1.1 KiB
PowerShell
7 years ago
|
#!/usr/bin/env pwsh
|
||
|
#Requires -Version 6
|
||
6 years ago
|
#Requires -Modules PSScriptAnalyzer, PSSA-PSCustomUseLiteralPath
|
||
7 years ago
|
|
||
|
Set-StrictMode -Version 2.0
|
||
|
$ErrorActionPreference = "Stop"
|
||
6 years ago
|
$WarningPreference = "Stop"
|
||
7 years ago
|
|
||
6 years ago
|
# Until https://github.com/PowerShell/PSScriptAnalyzer/issues/1217 is fixed we need to import Pester if it's
|
||
|
# available.
|
||
|
if (Get-Module -Name Pester -ListAvailable -ErrorAction SilentlyContinue) {
|
||
|
Import-Module -Name Pester
|
||
|
}
|
||
|
|
||
6 years ago
|
$LiteralPathRule = Import-Module -Name PSSA-PSCustomUseLiteralPath -PassThru
|
||
|
$LiteralPathRulePath = Join-Path -Path $LiteralPathRule.ModuleBase -ChildPath $LiteralPathRule.RootModule
|
||
|
|
||
|
$PSSAParams = @{
|
||
|
CustomRulePath = @($LiteralPathRulePath)
|
||
|
IncludeDefaultRules = $true
|
||
|
Setting = (Join-Path -Path $PSScriptRoot -ChildPath "settings.psd1")
|
||
|
}
|
||
|
|
||
7 years ago
|
$Results = @()
|
||
|
|
||
|
ForEach ($Path in $Args) {
|
||
6 years ago
|
$Retries = 3
|
||
|
|
||
|
Do {
|
||
|
Try {
|
||
6 years ago
|
$Results += Invoke-ScriptAnalyzer -Path $Path @PSSAParams 3> $null
|
||
6 years ago
|
$Retries = 0
|
||
|
}
|
||
|
Catch {
|
||
|
If (--$Retries -le 0) {
|
||
|
Throw
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
Until ($Retries -le 0)
|
||
7 years ago
|
}
|
||
|
|
||
|
ConvertTo-Json -InputObject $Results
|