Skip to content

Commit 9a6fe53

Browse files
author
Kapil Borle
authored
Update readme (#718)
* Fix back to table of contents link * Add doc for settings presets * Update table of contents
1 parent 1987389 commit 9a6fe53

File tree

1 file changed

+43
-13
lines changed

1 file changed

+43
-13
lines changed

README.md

+43-13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Table of Contents
2222
- [Tests](#tests)
2323
- [Suppressing Rules](#suppressing-rules)
2424
- [Settings Support in ScriptAnalyzer](#settings-support-in-scriptanalyzer)
25+
* [Built-in Presets](#built-in-presets)
2526
* [Explicit](#explicit)
2627
* [Implicit](#implicit)
2728
- [ScriptAnalyzer as a .NET library](#scriptanalyzer-as-a-net-library)
@@ -32,7 +33,7 @@ Table of Contents
3233

3334
<!-- tocstop -->
3435

35-
Introduction [&uarr;](#table-of-contents)
36+
Introduction
3637
============
3738
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.
3839
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.
4142
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,
4243
usage of Invoke-Expression etc. Additional functionalities such as exclude/include specific rules are also supported.
4344

45+
[Back to ToC](#table-of-contents)
4446

45-
Usage [&uarr;](#table-of-contents)
47+
Usage
4648
======================
49+
4750
``` PowerShell
4851
Get-ScriptAnalyzerRule [-CustomizedRulePath <string[]>] [-Name <string[]>] [<CommonParameters>] [-Severity <string[]>]
4952
5053
Invoke-ScriptAnalyzer [-Path] <string> [-CustomizedRulePath <string[]>] [-ExcludeRule <string[]>] [-IncludeRule <string[]>] [-Severity <string[]>] [-Recurse] [<CommonParameters>]
5154
```
5255

53-
Installation [&uarr;](#table-of-contents)
56+
[Back to ToC](#table-of-contents)
57+
58+
Installation
5459
============
5560

5661
### From PowerShell Gallery
@@ -135,7 +140,9 @@ cd /path/to/PSScriptAnalyzer/Tests/Rules
135140
Invoke-Pester
136141
```
137142

138-
Suppressing Rules [&uarr;](#table-of-contents)
143+
[Back to ToC](#table-of-contents)
144+
145+
Suppressing Rules
139146
=================
140147

141148
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()
220227

221228
**Note**: Rule suppression is currently supported only for built-in rules.
222229

223-
Settings Support in ScriptAnalyzer [&uarr;](#table-of-contents)
224-
========================================
230+
[Back to ToC](#table-of-contents)
231+
232+
Settings Support in ScriptAnalyzer
233+
==================================
225234
Settings that describe ScriptAnalyzer rules to include/exclude based on `Severity` can be created and supplied to
226235
`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.
227236

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.
239+
240+
```powershell
241+
PS> Invoke-ScriptAnalyzer -Path /path/to/module/ -Settings PSGallery -Recurse
242+
```
243+
244+
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+
228246
## Explicit
229247

230248
The following example excludes two rules from the default set of rules and any rule
@@ -269,7 +287,9 @@ Invoke-ScriptAnalyzer -Path "C:\path\to\project" -Recurse
269287

270288
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).
271289

272-
ScriptAnalyzer as a .NET library [&uarr;](#table-of-contents)
290+
[Back to ToC](#table-of-contents)
291+
292+
ScriptAnalyzer as a .NET library
273293
================================
274294

275295
ScriptAnalyzer engine and functionality can now be directly consumed as a library.
@@ -293,7 +313,9 @@ public System.Collections.Generic.IEnumerable<DiagnosticRecord> AnalyzePath(stri
293313
public System.Collections.Generic.IEnumerable<IRule> GetRule(string[] moduleNames, string[] ruleNames)
294314
```
295315

296-
Violation Correction [&uarr;](#table-of-contents)
316+
[Back to ToC](#table-of-contents)
317+
318+
Violation Correction
297319
====================
298320
Most violations can be fixed by replacing the violation causing content with the correct alternative.
299321

@@ -339,8 +361,10 @@ The main motivation behind having `SuggestedCorrections` is to enable quick-fix
339361
* MissingModuleManifestField.cs
340362
* UseToExportFieldsInManifest.cs
341363

342-
Project Management Dashboard [&uarr;](#table-of-contents)
343-
==============================
364+
[Back to ToC](#table-of-contents)
365+
366+
Project Management Dashboard
367+
============================
344368
You can track issues, pull requests, backlog items here:
345369

346370
[![Stories in progress](https://badge.waffle.io/PowerShell/PSScriptAnalyzer.png?label=In%20Progress&title=In%20Progress)](https://waffle.io/PowerShell/PSScriptAnalyzer)
@@ -353,7 +377,9 @@ Throughput Graph
353377

354378
[![Throughput Graph](https://graphs.waffle.io/powershell/psscriptanalyzer/throughput.svg)](https://waffle.io/powershell/psscriptanalyzer/metrics)
355379

356-
Contributing to ScriptAnalyzer [&uarr;](#table-of-contents)
380+
[Back to ToC](#table-of-contents)
381+
382+
Contributing to ScriptAnalyzer
357383
==============================
358384
You are welcome to contribute to this project. There are many ways to contribute:
359385

@@ -374,6 +400,10 @@ You might also read these two blog posts about contributing code: [Open Source C
374400

375401
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.
376402

377-
Code of Conduct [&uarr;](#table-of-contents)
403+
[Back to ToC](#table-of-contents)
404+
405+
Code of Conduct
378406
===============
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.
408+
409+
[Back to ToC](#table-of-contents)

0 commit comments

Comments
 (0)