Skip to content

Rkeithhill/is122 script analysis profile path #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// we run the custom script "compile" as defined in package.json
"args": ["run", "compile"],

// use the standard tsc problem matcher to find compile problems in the output.
// use the standard tsc problem matcher to find compile problems in the output.
"problemMatcher": "$tsc"
},
{
Expand All @@ -47,7 +47,7 @@
// The tsc compiler is started in watching mode
"isWatching": true,

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}
]
Expand Down
5 changes: 5 additions & 0 deletions examples/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
// Use a custom PowerShell Script Analyzer settings file for this workspace.
// Relative paths for this setting are always relative to the workspace root dir.
"powershell.scriptAnalysis.settingsPath": "./PSScriptAnalyzerSettings.psd1"
}
19 changes: 11 additions & 8 deletions examples/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,30 @@
###############################################################################
Properties {
# The name of your module should match the basename of the PSD1 file.
$ModuleName = (Get-Item $PSScriptRoot\*.psd1)[0].BaseName
$ModuleName = (Get-Item $PSScriptRoot\*.psd1 |
Foreach-Object {$null = Test-ModuleManifest -Path $_ -ErrorAction SilentlyContinue; if ($?) {$_}})[0].BaseName

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

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

# The following items will not be copied to the $PublishDir.
# Add items that should not be published with the module.
$Exclude = @(
(Split-Path $PSCommandPath -Leaf),
'Release',
'Tests',
'.git*',
'.vscode',
# The next three files are unique to this examples dir.
# These files are unique to this examples dir.
'DebugTest.ps1',
'Stop*.ps1',
'PSScriptAnalyzerSettings.psd1',
'Readme.md',
(Split-Path $PSCommandPath -Leaf)
'Stop*.ps1'
)

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

Expand Down
26 changes: 26 additions & 0 deletions examples/PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# The PowerShell Script Analyzer will generate a warning
# diagnostic record for this file due to a bug -
# https://github.com/PowerShell/PSScriptAnalyzer/issues/472
@{
# Only diagnostic records of the specified severity will be generated.
# Uncomment the following line if you only want Errors and Warnings but
# not Information diagnostic records.
#Severity = @('Error','Warning')

# Analyze **only** the following rules. Use IncludeRules when you want
# to invoke only a small subset of the defualt rules.
IncludeRules = @('PSAvoidDefaultValueSwitchParameter',
'PSMissingModuleManifestField',
'PSReservedCmdletChar',
'PSReservedParams',
'PSShouldProcess',
'PSUseApprovedVerbs',
'PSUseDeclaredVarsMoreThanAssigments')

# Do not analyze the following rules. Use ExcludeRules when you have
# commented out the IncludeRules settings above and want to include all
# the default rules except for those you exclude below.
# Note: if a rule is in both IncludeRules and ExcludeRules, the rule
# will be excluded.
#ExcludeRules = @('PSAvoidUsingWriteHost')
}
Binary file modified examples/SampleModule.psd1
Binary file not shown.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@
"default": true,
"description": "Enables real-time script analysis using PowerShell Script Analyzer."
},
"powershell.scriptAnalysis.settingsPath": {
"type": "string",
"default": "",
"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."
},
"powershell.developer.editorServicesHostPath": {
"type": "string",
"default": "../bin/",
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function resolveLanguageServerPath(settings: settingsManager.ISettings): string
console.log(" Resolved path to: " + editorServicesHostPath);
}
else {
// Use the default path in the plugin's 'bin' folder
// Use the default path in the extension's 'bin' folder
editorServicesHostPath =
path.join(
__dirname,
Expand Down
4 changes: 3 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import vscode = require('vscode');

export interface IScriptAnalysisSettings {
enable?: boolean
settingsPath: string
}

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

let defaultScriptAnalysisSettings = {
enable: true
enable: true,
settingsPath: ""
};

let defaultDeveloperSettings = {
Expand Down