Skip to content

Commit 9143f0a

Browse files
adamsktMarkMichaelis
authored andcommitted
Adding PS Script Analyzer settings with most rules turned on. (#29)
* Adding PS Script Analyzer settings with most rules turned on. * Update excluded rules to None. Remove gitignore entry for .vscode folder. * Added task for running Pester tests.
1 parent 3c6ee91 commit 9143f0a

File tree

4 files changed

+98
-4
lines changed

4 files changed

+98
-4
lines changed

.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ bld/
2121
[Bb]in/
2222
[Oo]bj/
2323

24-
#VSCODE
25-
26-
.vscode/
27-
2824
# Visual Studio 2015 cache/options directory
2925
.vs/
3026
# Uncomment if you have tasks that create the project's static files in wwwroot

.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"powershell.scriptAnalysis.settingsPath": "PSScriptAnalyzerSettings.psd1"
4+
}

.vscode/tasks.json

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Available variables which can be used inside of strings.
2+
// ${workspaceRoot}: the root folder of the team
3+
// ${file}: the current opened file
4+
// ${relativeFile}: the current opened file relative to workspaceRoot
5+
// ${fileBasename}: the current opened file's basename
6+
// ${fileDirname}: the current opened file's dirname
7+
// ${fileExtname}: the current opened file's extension
8+
// ${cwd}: the current working directory of the spawned process
9+
{
10+
// See https://go.microsoft.com/fwlink/?LinkId=733558
11+
// for the documentation about the tasks.json format
12+
"version": "0.1.0",
13+
14+
// Start PowerShell
15+
"windows": {
16+
"command": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
17+
},
18+
"linux": {
19+
"command": "/usr/bin/powershell"
20+
},
21+
"osx": {
22+
"command": "/usr/local/bin/powershell"
23+
},
24+
25+
// The command is a shell script
26+
"isShellCommand": true,
27+
28+
// Show the output window always
29+
"showOutput": "always",
30+
31+
"args": [
32+
"-NoProfile", "-ExecutionPolicy", "Bypass"
33+
],
34+
35+
// Associate with test task runner
36+
"tasks": [
37+
{
38+
"taskName": "Test",
39+
"suppressTaskName": true,
40+
"isTestCommand": true,
41+
"showOutput": "always",
42+
"args": [
43+
"Write-Host 'Invoking Pester'; Import-Module Pester; Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true};",
44+
"Invoke-Command { Write-Host 'Completed Test task in task runner.' }"
45+
],
46+
"problemMatcher": [
47+
{
48+
"owner": "powershell",
49+
"fileLocation": ["absolute"],
50+
"severity": "error",
51+
"pattern": [
52+
{
53+
"regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$",
54+
"message": 1
55+
},
56+
{
57+
"regexp": "^\\s+at\\s+[^,]+,\\s*(.*?):\\s+line\\s+(\\d+)$",
58+
"file": 1,
59+
"line": 2
60+
}
61+
]
62+
}
63+
]
64+
}
65+
]
66+
}

PSScriptAnalyzerSettings.psd1

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# The PowerShell Script Analyzer will generate a warning
2+
# diagnostic record for this file due to a bug -
3+
# https://github.com/PowerShell/PSScriptAnalyzer/issues/472
4+
@{
5+
# Only diagnostic records of the specified severity will be generated.
6+
# Uncomment the following line if you only want Errors and Warnings but
7+
# not Information diagnostic records.
8+
#Severity = @('Error','Warning')
9+
10+
# Analyze **only** the following rules. Use IncludeRules when you want
11+
# to invoke only a small subset of the defualt rules.
12+
#IncludeRules = @('PSAvoidDefaultValueSwitchParameter',
13+
# 'PSMisleadingBacktick',
14+
# 'PSMissingModuleManifestField',
15+
# 'PSReservedCmdletChar',
16+
# 'PSReservedParams',
17+
# 'PSShouldProcess',
18+
# 'PSUseApprovedVerbs',
19+
# 'PSAvoidUsingAliases',
20+
# 'PSUseDeclaredVarsMoreThanAssigments')
21+
22+
# Do not analyze the following rules. Use ExcludeRules when you have
23+
# commented out the IncludeRules settings above and want to include all
24+
# the default rules except for those you exclude below.
25+
# Note: if a rule is in both IncludeRules and ExcludeRules, the rule
26+
# will be excluded.
27+
ExcludeRules = @()
28+
}

0 commit comments

Comments
 (0)