From c9d485dd45b6da58b48f443e13276c8f4ea4735e Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Sun, 6 May 2018 13:09:59 -0600 Subject: [PATCH 1/4] Updates to Examples PSSA settings file to include more rule config --- examples/PSScriptAnalyzerSettings.psd1 | 49 ++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/examples/PSScriptAnalyzerSettings.psd1 b/examples/PSScriptAnalyzerSettings.psd1 index 2834ae976c..65d16cd3ea 100644 --- a/examples/PSScriptAnalyzerSettings.psd1 +++ b/examples/PSScriptAnalyzerSettings.psd1 @@ -1,6 +1,5 @@ -# The PowerShell Script Analyzer will generate a warning -# diagnostic record for this file due to a bug - -# https://github.com/PowerShell/PSScriptAnalyzer/issues/472 +# For more information on PSScriptAnalyzer settings see: +# https://github.com/PowerShell/PSScriptAnalyzer/blob/master/README.md#settings-support-in-scriptanalyzer @{ # Only diagnostic records of the specified severity will be generated. # Uncomment the following line if you only want Errors and Warnings but @@ -25,4 +24,48 @@ # Note: if a rule is in both IncludeRules and ExcludeRules, the rule # will be excluded. #ExcludeRules = @('PSAvoidUsingWriteHost') + + # You can use rule configuration to configure rules that support it: + #Rules = @{ + # PSAlignAssignmentStatement = @{ + # Enable = $true + # CheckHashtable = $true + # } + # PSAvoidUsingCmdletAliases = @{ + # Whitelist = @("cd") + # } + # PSPlaceCloseBrace = @{ + # Enable = $true + # NoEmptyLineBefore = $false + # IgnoreOneLineBlock = $true + # NewLineAfter = $true + # } + # PSPlaceOpenBrace = @{ + # Enable = $true + # OnSameLine = $true + # NewLineAfter = $true + # IgnoreOneLineBlock = $true + # } + # PSProvideCommentHelp = @{ + # Enable = $true + # ExportedOnly = $false + # BlockComment = $true + # VSCodeSnippetCorrection = $false + # Placement = "before" + # } + # PSUseCompatibleCmdlets = @{ + # compatibility = @("core-6.0.0-alpha-windows", "core-6.0.0-alpha-linux") + # } + # PSUseConsistentIndentation = @{ + # Enable = $true + # IndentationSize = 4 + # } + # PSUseConsistentWhitespace = @{ + # Enable = $true + # CheckOpenBrace = $true + # CheckOpenParen = $true + # CheckOperator = $true + # CheckSeparator = $true + # } + # } } From a457e6dd1ed3c66789078b9fc0a10cb0a08b61fc Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Sun, 6 May 2018 16:35:28 -0600 Subject: [PATCH 2/4] Address PR feedback --- examples/PSScriptAnalyzerSettings.psd1 | 44 ++++---------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/examples/PSScriptAnalyzerSettings.psd1 b/examples/PSScriptAnalyzerSettings.psd1 index 65d16cd3ea..9d3b7094f7 100644 --- a/examples/PSScriptAnalyzerSettings.psd1 +++ b/examples/PSScriptAnalyzerSettings.psd1 @@ -1,5 +1,12 @@ +# Use the PowerShell extension setting `powershell.scriptAnalysis.settingsPath` to get the current workspace +# to use this PSScriptAnalyzerSettings.psd1 file to configure code analysis in Visual Studio Code. +# This setting is configured in the workspace's `.vscode\settings.json`. +# # For more information on PSScriptAnalyzer settings see: # https://github.com/PowerShell/PSScriptAnalyzer/blob/master/README.md#settings-support-in-scriptanalyzer +# +# You can see the predefined PSScriptAnalyzer settings here: +# https://github.com/PowerShell/PSScriptAnalyzer/tree/master/Engine/Settings @{ # Only diagnostic records of the specified severity will be generated. # Uncomment the following line if you only want Errors and Warnings but @@ -27,45 +34,8 @@ # You can use rule configuration to configure rules that support it: #Rules = @{ - # PSAlignAssignmentStatement = @{ - # Enable = $true - # CheckHashtable = $true - # } # PSAvoidUsingCmdletAliases = @{ # Whitelist = @("cd") # } - # PSPlaceCloseBrace = @{ - # Enable = $true - # NoEmptyLineBefore = $false - # IgnoreOneLineBlock = $true - # NewLineAfter = $true - # } - # PSPlaceOpenBrace = @{ - # Enable = $true - # OnSameLine = $true - # NewLineAfter = $true - # IgnoreOneLineBlock = $true - # } - # PSProvideCommentHelp = @{ - # Enable = $true - # ExportedOnly = $false - # BlockComment = $true - # VSCodeSnippetCorrection = $false - # Placement = "before" - # } - # PSUseCompatibleCmdlets = @{ - # compatibility = @("core-6.0.0-alpha-windows", "core-6.0.0-alpha-linux") - # } - # PSUseConsistentIndentation = @{ - # Enable = $true - # IndentationSize = 4 - # } - # PSUseConsistentWhitespace = @{ - # Enable = $true - # CheckOpenBrace = $true - # CheckOpenParen = $true - # CheckOperator = $true - # CheckSeparator = $true - # } # } } From 4340dcf8faeec7086a53c291790bf8817f486153 Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Sun, 6 May 2018 17:12:30 -0600 Subject: [PATCH 3/4] Fix typo - defualt --- examples/PSScriptAnalyzerSettings.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/PSScriptAnalyzerSettings.psd1 b/examples/PSScriptAnalyzerSettings.psd1 index 9d3b7094f7..f232a19384 100644 --- a/examples/PSScriptAnalyzerSettings.psd1 +++ b/examples/PSScriptAnalyzerSettings.psd1 @@ -14,7 +14,7 @@ #Severity = @('Error','Warning') # Analyze **only** the following rules. Use IncludeRules when you want - # to invoke only a small subset of the defualt rules. + # to invoke only a small subset of the default rules. IncludeRules = @('PSAvoidDefaultValueSwitchParameter', 'PSMisleadingBacktick', 'PSMissingModuleManifestField', From 6840c48d6ae6555a2850cb8bd33df14e2b464e7b Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Mon, 7 May 2018 15:39:06 -0600 Subject: [PATCH 4/4] Whitespace only change --- examples/PSScriptAnalyzerSettings.psd1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/PSScriptAnalyzerSettings.psd1 b/examples/PSScriptAnalyzerSettings.psd1 index f232a19384..31fccb78d4 100644 --- a/examples/PSScriptAnalyzerSettings.psd1 +++ b/examples/PSScriptAnalyzerSettings.psd1 @@ -34,8 +34,8 @@ # You can use rule configuration to configure rules that support it: #Rules = @{ - # PSAvoidUsingCmdletAliases = @{ - # Whitelist = @("cd") - # } - # } + # PSAvoidUsingCmdletAliases = @{ + # Whitelist = @("cd") + # } + #} }