Skip to content

Commit 60987b7

Browse files
committed
Merge pull request #137 from rkeithhill/rkeithhill/is122-scriptAnalysisProfilePath
Rkeithhill/is122 script analysis profile path
2 parents e4f3dcc + 5ddd2c9 commit 60987b7

File tree

8 files changed

+53
-12
lines changed

8 files changed

+53
-12
lines changed

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// we run the custom script "compile" as defined in package.json
3232
"args": ["run", "compile"],
3333

34-
// use the standard tsc problem matcher to find compile problems in the output.
34+
// use the standard tsc problem matcher to find compile problems in the output.
3535
"problemMatcher": "$tsc"
3636
},
3737
{
@@ -47,7 +47,7 @@
4747
// The tsc compiler is started in watching mode
4848
"isWatching": true,
4949

50-
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
50+
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
5151
"problemMatcher": "$tsc-watch"
5252
}
5353
]

examples/.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
// Use a custom PowerShell Script Analyzer settings file for this workspace.
3+
// Relative paths for this setting are always relative to the workspace root dir.
4+
"powershell.scriptAnalysis.settingsPath": "./PSScriptAnalyzerSettings.psd1"
5+
}

examples/Build.ps1

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,30 @@
6565
###############################################################################
6666
Properties {
6767
# The name of your module should match the basename of the PSD1 file.
68-
$ModuleName = (Get-Item $PSScriptRoot\*.psd1)[0].BaseName
68+
$ModuleName = (Get-Item $PSScriptRoot\*.psd1 |
69+
Foreach-Object {$null = Test-ModuleManifest -Path $_ -ErrorAction SilentlyContinue; if ($?) {$_}})[0].BaseName
6970

7071
# Path to the release notes file. Set to $null if the release notes reside in the manifest file.
7172
$ReleaseNotesPath = "$PSScriptRoot\ReleaseNotes.md"
7273

7374
# The directory used to publish the module from. If you are using Git, the
74-
# $PublishDir should be ignored if it is under the workspace directory.
75-
$PublishDir = "$PSScriptRoot\Release\$ModuleName"
75+
# $PublishRootDir should be ignored if it is under the workspace directory.
76+
$PublishRootDir = "$PSScriptRoot\Release"
77+
$PublishDir = "$PublishRootDir\$ModuleName"
7678

7779
# The following items will not be copied to the $PublishDir.
7880
# Add items that should not be published with the module.
7981
$Exclude = @(
82+
(Split-Path $PSCommandPath -Leaf),
8083
'Release',
8184
'Tests',
8285
'.git*',
8386
'.vscode',
84-
# The next three files are unique to this examples dir.
87+
# These files are unique to this examples dir.
8588
'DebugTest.ps1',
86-
'Stop*.ps1',
89+
'PSScriptAnalyzerSettings.psd1',
8790
'Readme.md',
88-
(Split-Path $PSCommandPath -Leaf)
91+
'Stop*.ps1'
8992
)
9093

9194
# Name of the repository you wish to publish to. Default repo is the PSGallery.
@@ -170,8 +173,8 @@ Task Clean -depends Init -requiredVariables PublishDir {
170173
# Sanity check the dir we are about to "clean". If $PublishDir were to
171174
# inadvertently get set to $null, the Remove-Item commmand removes the
172175
# contents of \*. That's a bad day. Ask me how I know? :-(
173-
if ($PublishDir.Contains($PSScriptRoot)) {
174-
Remove-Item $PublishDir\* -Recurse -Force
176+
if ($PublishRootDir.Contains($PSScriptRoot)) {
177+
Remove-Item $PublishRootDir\* -Recurse -Force
175178
}
176179
}
177180

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
'PSMissingModuleManifestField',
14+
'PSReservedCmdletChar',
15+
'PSReservedParams',
16+
'PSShouldProcess',
17+
'PSUseApprovedVerbs',
18+
'PSUseDeclaredVarsMoreThanAssigments')
19+
20+
# Do not analyze the following rules. Use ExcludeRules when you have
21+
# commented out the IncludeRules settings above and want to include all
22+
# the default rules except for those you exclude below.
23+
# Note: if a rule is in both IncludeRules and ExcludeRules, the rule
24+
# will be excluded.
25+
#ExcludeRules = @('PSAvoidUsingWriteHost')
26+
}

examples/SampleModule.psd1

-3.87 KB
Binary file not shown.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@
245245
"default": true,
246246
"description": "Enables real-time script analysis using PowerShell Script Analyzer."
247247
},
248+
"powershell.scriptAnalysis.settingsPath": {
249+
"type": "string",
250+
"default": "",
251+
"description": "Specifies the path to a PowerShell Script Analyzer settings file. Use either an absolute path (to override the default settings for all projects) or use a path relative to your workspace."
252+
},
248253
"powershell.developer.editorServicesHostPath": {
249254
"type": "string",
250255
"default": "../bin/",

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function resolveLanguageServerPath(settings: settingsManager.ISettings): string
164164
console.log(" Resolved path to: " + editorServicesHostPath);
165165
}
166166
else {
167-
// Use the default path in the plugin's 'bin' folder
167+
// Use the default path in the extension's 'bin' folder
168168
editorServicesHostPath =
169169
path.join(
170170
__dirname,

src/settings.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import vscode = require('vscode');
88

99
export interface IScriptAnalysisSettings {
1010
enable?: boolean
11+
settingsPath: string
1112
}
1213

1314
export interface IDeveloperSettings {
@@ -27,7 +28,8 @@ export function load(myPluginId: string): ISettings {
2728
let configuration = vscode.workspace.getConfiguration(myPluginId);
2829

2930
let defaultScriptAnalysisSettings = {
30-
enable: true
31+
enable: true,
32+
settingsPath: ""
3133
};
3234

3335
let defaultDeveloperSettings = {

0 commit comments

Comments
 (0)