summaryrefslogtreecommitdiffstats
path: root/src/pmdk/utils/ps_analyze.ps1
blob: b0e6bfe9e3d26c689d4c25f00b9d8683ec0301d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017, Intel Corporation
#
# ps_analyze -- script to analyze ps1 files
#

Write-Output "Starting PSScript analyzing ..."

$scriptdir = Split-Path -Parent $PSCommandPath
$rootdir = $scriptdir + "\.."
$detected = 0

$include = @("*.ps1" )
Get-ChildItem -Path $rootdir -Recurse -Include $include  | `
    Where-Object { $_.FullName -notlike "*test*" } | `
    ForEach-Object {
        $analyze_result = Invoke-ScriptAnalyzer -Path $_.FullName
        if ($analyze_result) {
            $detected = $detected + $analyze_result.Count
            Write-Output $_.FullName
            Write-Output $analyze_result
        }
    }

if ($detected) {
    Write-Output "PSScriptAnalyzer FAILED. Issues detected: $detected"
    Exit 1
} else {
    Write-Output "PSScriptAnalyzer PASSED. No issue detected."
    Exit 0
}