Skip to content

Commit 151e8f1

Browse files
author
Kapil Borle
committed
Update settings documentation in README
1 parent 61877f9 commit 151e8f1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ Param(
174174
Settings Support in ScriptAnalyzer
175175
========================================
176176
Settings that describe ScriptAnalyzer rules to include/exclude based on `Severity` can be created and supplied to
177-
`Invoke-ScriptAnalyzer` using the `Setting` parameter. This enables a user to create a custom configuration for a specific environment.
177+
`Invoke-ScriptAnalyzer` using the `Setting` parameter. This enables a user to create a custom configuration for a specific environment. We support the following modes for specifying the settings file.
178178

179-
Using Settings support:
179+
## Explicit
180180

181181
The following example excludes two rules from the default set of rules and any rule
182182
that does not output an Error or Warning diagnostic record.
183183

184184
``` PowerShell
185-
# ScriptAnalyzerSettings.psd1
185+
# PSScriptAnalyzerSettings.psd1
186186
@{
187187
Severity=@('Error','Warning')
188188
ExcludeRules=@('PSAvoidUsingCmdletAliases',
@@ -199,7 +199,7 @@ Invoke-ScriptAnalyzer -Path MyScript.ps1 -Setting ScriptAnalyzerSettings.psd1
199199
The next example selects a few rules to execute instead of all the default rules.
200200

201201
``` PowerShell
202-
# ScriptAnalyzerSettings.psd1
202+
# PSScriptAnalyzerSettings.psd1
203203
@{
204204
IncludeRules=@('PSAvoidUsingPlainTextForPassword',
205205
'PSAvoidUsingConvertToSecureStringWithPlainText')
@@ -211,6 +211,15 @@ Then invoke that settings file when using:
211211
Invoke-ScriptAnalyzer -Path MyScript.ps1 -Setting ScriptAnalyzerSettings.psd1
212212
```
213213

214+
## Implicit
215+
If you place a PSScriptAnayzer settings file named `PSScriptAnalyzerSettings.psd1` in your project root, PSScriptAnalyzer will discover it if you pass the project root as the `Path` parameter.
216+
217+
```PowerShell
218+
Invoke-ScriptAnalyzer -Path "C:\path\to\project" -Recurse
219+
```
220+
221+
Note that providing settings explicitly takes higher precedence over this implicit mode. Sample settings files are provided [here](https://github.com/PowerShell/PSScriptAnalyzer/tree/development/Engine/Settings).
222+
214223
ScriptAnalyzer as a .NET library
215224
================================
216225

0 commit comments

Comments
 (0)