Skip to content

Commit

Permalink
Move psscriptanalzyer folder and associated PSSA config file, as the …
Browse files Browse the repository at this point in the history
….github folder was not being loaded into the runner.
  • Loading branch information
jonnybottles committed Nov 20, 2024
1 parent 8aaa678 commit f5cedc1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: local
hooks:
- id: powershell-script-analyzer
name: PowerShell Script Analyzer
entry: pwsh
args:
- -NoProfile
- -ExecutionPolicy
- Bypass
- -Command
- |
$ErrorActionPreference = 'Stop'
$settings = Join-Path (Get-Location) 'Hawk/tests/psscriptanalyzer/PSScriptAnalyzerSettings.psd1'
$files = git diff --cached --name-only --diff-filter=AM | Where-Object { $_ -match '\.(ps1|psm1|psd1)$' }
$hasErrors = $false
foreach ($file in $files) {
Write-Host "Analyzing $file..."
$results = Invoke-ScriptAnalyzer -Path $file -Settings $settings
if ($results) {
$results | Format-Table -AutoSize
$hasErrors = $true
}
}
if ($hasErrors) { exit 1 }
language: system
types: [powershell]
2 changes: 1 addition & 1 deletion Hawk/tests/general/Test-PreCommitHook.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# 3. Observe the PSScriptAnalyzer warnings/errors

#region Good Code Examples - These will pass PSScriptAnalyzer
# add comment to testss
# add comment to testsss
function Test-GoodFunction {
[CmdletBinding()]
param (
Expand Down

0 comments on commit f5cedc1

Please sign in to comment.