You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-13
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,7 @@ Table of Contents
22
22
-[Tests](#tests)
23
23
-[Suppressing Rules](#suppressing-rules)
24
24
-[Settings Support in ScriptAnalyzer](#settings-support-in-scriptanalyzer)
25
+
*[Built-in Presets](#built-in-presets)
25
26
*[Explicit](#explicit)
26
27
*[Implicit](#implicit)
27
28
-[ScriptAnalyzer as a .NET library](#scriptanalyzer-as-a-net-library)
@@ -32,7 +33,7 @@ Table of Contents
32
33
33
34
<!-- tocstop -->
34
35
35
-
Introduction[↑](#table-of-contents)
36
+
Introduction
36
37
============
37
38
PSScriptAnalyzer is a static code checker for Windows PowerShell modules and scripts. PSScriptAnalyzer checks the quality of Windows PowerShell code by running a set of rules.
38
39
The rules are based on PowerShell best practices identified by PowerShell Team and the community. It generates DiagnosticResults (errors and warnings) to inform users about potential
@@ -41,16 +42,20 @@ code defects and suggests possible solutions for improvements.
41
42
PSScriptAnalyzer is shipped with a collection of built-in rules that checks various aspects of PowerShell code such as presence of uninitialized variables, usage of PSCredential Type,
42
43
usage of Invoke-Expression etc. Additional functionalities such as exclude/include specific rules are also supported.
@@ -135,7 +140,9 @@ cd /path/to/PSScriptAnalyzer/Tests/Rules
135
140
Invoke-Pester
136
141
```
137
142
138
-
Suppressing Rules [↑](#table-of-contents)
143
+
[Back to ToC](#table-of-contents)
144
+
145
+
Suppressing Rules
139
146
=================
140
147
141
148
You can suppress a rule by decorating a script/function or script/function parameter with .NET's [SuppressMessageAttribute](https://msdn.microsoft.com/en-us/library/system.diagnostics.codeanalysis.suppressmessageattribute.aspx).
@@ -220,11 +227,22 @@ Param()
220
227
221
228
**Note**: Rule suppression is currently supported only for built-in rules.
222
229
223
-
Settings Support in ScriptAnalyzer [↑](#table-of-contents)
224
-
========================================
230
+
[Back to ToC](#table-of-contents)
231
+
232
+
Settings Support in ScriptAnalyzer
233
+
==================================
225
234
Settings that describe ScriptAnalyzer rules to include/exclude based on `Severity` can be created and supplied to
226
235
`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.
227
236
237
+
## Built-in Presets
238
+
ScriptAnalyzer ships a set of built-in presets that can be used to analyze scripts. For example, if the user wants to run *PowerShell Gallery* rules on their module, then they use the following command.
Along with `PSGallery` there are a few other built-in presets, including, `DSC` and `CodeFormatting`, that can be used. These presets can be tab completed for the `Settings` parameter.
245
+
228
246
## Explicit
229
247
230
248
The following example excludes two rules from the default set of rules and any rule
Note that providing settings explicitly takes higher precedence over this implicit mode. Sample settings files are provided [here](https://github.com/PowerShell/PSScriptAnalyzer/tree/master/Engine/Settings).
271
289
272
-
ScriptAnalyzer as a .NET library [↑](#table-of-contents)
290
+
[Back to ToC](#table-of-contents)
291
+
292
+
ScriptAnalyzer as a .NET library
273
293
================================
274
294
275
295
ScriptAnalyzer engine and functionality can now be directly consumed as a library.
@@ -293,7 +313,9 @@ public System.Collections.Generic.IEnumerable<DiagnosticRecord> AnalyzePath(stri
You can track issues, pull requests, backlog items here:
345
369
346
370
[](https://waffle.io/PowerShell/PSScriptAnalyzer)
Contributing to ScriptAnalyzer [↑](#table-of-contents)
380
+
[Back to ToC](#table-of-contents)
381
+
382
+
Contributing to ScriptAnalyzer
357
383
==============================
358
384
You are welcome to contribute to this project. There are many ways to contribute:
359
385
@@ -374,6 +400,10 @@ You might also read these two blog posts about contributing code: [Open Source C
374
400
375
401
Before submitting a feature or substantial code contribution, please discuss it with the Windows PowerShell team via [Issues](https://github.com/PowerShell/PSScriptAnalyzer/issues), and ensure it follows the product roadmap. Note that all code submissions will be rigorously reviewed by the Windows PowerShell Team. Only those that meet a high bar for both quality and roadmap fit will be merged into the source.
376
402
377
-
Code of Conduct [↑](#table-of-contents)
403
+
[Back to ToC](#table-of-contents)
404
+
405
+
Code of Conduct
378
406
===============
379
-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
407
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
0 commit comments