Skip to content

Commit 06f596e

Browse files
PSScriptAnalyzer and VS Code tooling (#224)
This adds the following files: * `launch.json` - used by vscode in order to debug PowerShellForGitHub with ease * `PSScriptAnalyzerSettings.psd1` - used by PSSA to check syntax and also by VS Code to show problems for all rules PSSA Rules: https://github.com./PowerShell/PSScriptAnalyzer/tree/master/RuleDocumentation Specifically: https://github.com./PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/UseCompatibleSyntax.md
1 parent 618398e commit 06f596e

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

Diff for: .vscode/launch.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
// Run this launch config and then set breakpoints in your module.
9+
// Then you can `Import-Module -Force ./PowerShellForGitHub.psd1`
10+
// and run a function that will hit the breakpoint.
11+
"name": "PowerShell: Interactive Session",
12+
"type": "PowerShell",
13+
"request": "launch",
14+
"cwd": ""
15+
}
16+
]
17+
}

Diff for: CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Update-Module -Name PSScriptAnalyzer
153153
Once it's installed (or updated), from the root of your enlistment simply call
154154

155155
```powershell
156-
Invoke-ScriptAnalyzer -Path .\ -Recurse
156+
Invoke-ScriptAnalyzer -Settings ./PSScriptAnalyzerSettings.psd1 -Path ./ -Recurse
157157
```
158158

159159
That should return with no output. If you see any output when calling that command,

Diff for: PSScriptAnalyzerSettings.psd1

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# PSScriptAnalyzerSettings.psd1
2+
# Settings for PSScriptAnalyzer invocation.
3+
# All default rules are also enabled.
4+
@{
5+
Rules = @{
6+
PSUseCompatibleSyntax = @{
7+
# This turns the rule on (setting it to false will turn it off)
8+
Enable = $true
9+
10+
# Simply list the targeted versions of PowerShell here
11+
TargetVersions = @(
12+
'4.0',
13+
'5.1',
14+
'6.2',
15+
'7.0'
16+
)
17+
}
18+
}
19+
}

Diff for: build/pipelines/templates/run-staticAnalysis.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ steps:
99
displayName: 'Install PSScriptAnalyzer'
1010
1111
- powershell: |
12-
$results = try { Invoke-ScriptAnalyzer -Path ./ –Recurse -ErrorAction Stop } catch { $_.Exception.StackTrace; throw }
12+
$results = try { Invoke-ScriptAnalyzer -Settings ./PSScriptAnalyzerSettings.psd1 -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

Diff for: build/scripts/ConvertTo-NUnitXml.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Overwrite the file at Path if it exists.
1717
1818
.EXAMPLE
19-
$results = Invoke-ScriptAnalyzer -Path ./ -Recurse
19+
$results = Invoke-ScriptAnalyzer -Settings ./PSScriptAnalyzerSettings.psd1 -Path ./ -Recurse
2020
.\ConverTo-NUnitXml.ps1 -ScriptAnalyzerResult $results -Path ./PSScriptAnalyzerFailures.xml
2121
#>
2222
[CmdletBinding()]

0 commit comments

Comments
 (0)