Skip to content

Commit 1f63817

Browse files
authored
CI: Report full stack trace if ScriptAnalyzer throws an error and improve ScriptAnalyzer installation to not skip publisher and check and not allow clobber (#236)
#221 reported that this repo causes PSScriptAnalyzer to sporadically throw an error. In order to report the full error needed for analysis, report the full stack trace. In order to make this easier, I've updated `Invoke-ScriptAnalyzer` to run within a `try/catch using -ErrorAction Stop`, and report any error found with `$_.Exception.StackTrace` before re-throwing the error.
1 parent 08ff284 commit 1f63817

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ Thank you to all of our contributors, no matter how big or small the contributio
486486
- **[Shannon Deminick (@Shazwazza)](http://github.com/Shazwazza)**
487487
- **[Jess Pomfret (@jpomfret)](https://github.com/jpomfret)**
488488
- **[Giuseppe Campanelli (@themilanfan)](https://github.com/themilanfan)**
489+
- **[Christoph Bergmeister (@bergmeister)](https://github.com/bergmeister)**
489490

490491
----------
491492

build/pipelines/templates/run-staticAnalysis.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
steps:
77
- powershell: |
8-
Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose
8+
Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Scope CurrentUser -Force -Verbose
99
displayName: 'Install PSScriptAnalyzer'
1010
1111
- powershell: |
12-
$results = Invoke-ScriptAnalyzer -Path ./ –Recurse
12+
$results = try { Invoke-ScriptAnalyzer -Path ./ –Recurse -ErrorAction Stop } catch { $_.Exception.StackTrace; throw }
1313
$results | ForEach-Object { Write-Host "##vso[task.logissue type=$($_.Severity);sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)" }
1414
1515
$null = New-Item -Path ..\ -Name ScriptAnalyzer -ItemType Directory -Force

0 commit comments

Comments
 (0)