Skip to content

Commit 260a573

Browse files
author
Kapil Borle
authored
Fix markdown headings in rule documentation (#716)
* Fix markdown headers in rule documentation Most rule documentation markdown files had headers of the form '#header' or '##header'. This commit fixes those issues. Some documentation markdown markdown files were in UTF8 and the rest in ASCII. This commit converts all markdown files to ASCII encoding. * Add new line after heading, if not present
1 parent 65a1ca1 commit 260a573

File tree

51 files changed

+588
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+588
-281
lines changed

RuleDocumentation/AvoidAlias.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# AvoidAlias
1+
# AvoidAlias
2+
23
**Severity Level: Warning**
34

45
## Description
6+
57
An alias is an alternate name or nickname for a CMDLet or for a command element, such as a function, script, file, or executable file.
68
You can use the alias instead of the command name in any Windows PowerShell commands.
79

@@ -13,13 +15,16 @@ When developing PowerShell content that will potentially need to be maintained o
1315
The use of full command names also allows for syntax highlighting in sites and applications like GitHub and Visual Studio Code.
1416

1517
## How to Fix
18+
1619
Use the full cmdlet name and not an alias.
1720

1821
## Alias Whitelist
22+
1923
To prevent `PSScriptAnalyzer` from flagging your preferred aliases, create a whitelist of the aliases in your settings file and point `PSScriptAnalyzer` to use the settings file. For example, to disable `PSScriptAnalyzer` from flagging `cd`, which is an alias of `Set-Location`, set the settings file content to the following.
2024

2125
```PowerShell
2226
# PSScriptAnalyzerSettings.psd1
27+
2328
@{
2429
'Rules' = @{
2530
'PSAvoidUsingCmdletAliases' = @{
@@ -30,12 +35,15 @@ To prevent `PSScriptAnalyzer` from flagging your preferred aliases, create a whi
3035
```
3136

3237
## Example
33-
### Wrong:
38+
39+
### Wrong?
40+
3441
``` PowerShell
3542
gps | Where-Object {$_.WorkingSet -gt 20000000}
3643
```
3744

3845
### Correct:
46+
3947
``` PowerShell
4048
Get-Process | Where-Object {$_.WorkingSet -gt 20000000}
4149
```

RuleDocumentation/AvoidDefaultTrueValueSwitchParameter.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
#AvoidDefaultTrueValueSwitchParameter
1+
# AvoidDefaultTrueValueSwitchParameter
2+
23
**Severity Level: Warning**
34

4-
##Description
5+
## Description
6+
57
Switch parameters for commands should default to false.
68

7-
##How to Fix
9+
## How
10+
811
Change the default value of the switch parameter to be false.
912

10-
##Example
11-
###Wrong:
13+
## Example
14+
15+
### Wrong
16+
1217
``` PowerShell
1318
function Test-Script
1419
{
@@ -25,7 +30,8 @@ function Test-Script
2530
}
2631
```
2732

28-
###Correct:
33+
### Correct
34+
2935
``` PowerShell
3036
function Test-Script
3137
{

RuleDocumentation/AvoidEmptyCatchBlock.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
#AvoidEmptyCatchBlock
1+
# AvoidEmptyCatchBlock
2+
23
**Severity Level: Warning**
34

4-
##Description
5+
## Description
6+
57
Empty catch blocks are considered a poor design choice as they result in the errors occurring in a `try` block not being acted upon.
68

79
While this does not inherently lead to issues, they should be avoided wherever possible.
810

9-
##How to Fix
11+
## How
12+
1013
Use ```Write-Error``` or ```throw``` statements within the catch block.
1114

12-
##Example
13-
###Wrong:
15+
## Example
16+
17+
### Wrong
18+
1419
``` PowerShell
1520
try
1621
{
@@ -21,7 +26,8 @@ catch [DivideByZeroException]
2126
}
2227
```
2328

24-
###Correct:
29+
### Correct
30+
2531
``` PowerShell
2632
try
2733
{
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
#AvoidGlobalAliases
1+
# AvoidGlobalAliases
2+
23
**Severity Level: Warning**
34

4-
##Description
5+
## Description
6+
57
Globally scoped aliases override existing aliases within the sessions with matching names. This name collision can cause difficult to debug issues for consumers of modules and scripts.
68

79

810
To understand more about scoping, see ```Get-Help about_Scopes```.
911

10-
##How to Fix
12+
## How
13+
1114
Use other scope modifiers for new aliases.
1215

13-
##Example
14-
###Wrong:
16+
## Example
17+
18+
### Wrong
19+
1520
``` PowerShell
1621
New-Alias -Name Name -Value Value -Scope "Global"
1722
```
1823

19-
###Correct:
24+
### Correct
25+
2026
``` PowerShell
2127
New-Alias -Name Name1 -Value Value
22-
```
28+
```
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
#AvoidGlobalFunctions
1+
# AvoidGlobalFunctions
2+
23
**Severity Level: Warning**
34

4-
##Description
5+
## Description
6+
57
Globally scoped functions override existing functions within the sessions with matching names. This name collision can cause difficult to debug issues for consumers of modules.
68

79

810
To understand more about scoping, see ```Get-Help about_Scopes```.
911

10-
##How to Fix
12+
## How
13+
1114
Use other scope modifiers for functions.
1215

13-
##Example
14-
###Wrong:
16+
## Example
17+
18+
### Wrong
19+
1520
``` PowerShell
1621
function global:functionName {}
1722
```
1823

19-
###Correct:
24+
### Correct
25+
2026
``` PowerShell
2127
function functionName {}
22-
```
28+
```

RuleDocumentation/AvoidGlobalVars.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#AvoidGlobalVars
1+
# AvoidGlobalVars
2+
23
**Severity Level: Warning**
34

4-
##Description
5+
## Description
6+
57
A variable is a unit of memory in which values are stored. Windows PowerShell controls access to variables, functions, aliases, and drives through a mechanism known as scoping.
68
Variables and functions that are present when Windows PowerShell starts have been created in the global scope.
79

@@ -12,11 +14,14 @@ Globally scoped variables include:
1214

1315
To understand more about scoping, see ```Get-Help about_Scopes```.
1416

15-
##How to Fix
17+
## How
18+
1619
Use other scope modifiers for variables.
1720

18-
##Example
19-
###Wrong:
21+
## Example
22+
23+
### Wrong
24+
2025
``` PowerShell
2126
$Global:var1 = $null
2227
function Test-NotGlobal ($var)
@@ -25,7 +30,8 @@ function Test-NotGlobal ($var)
2530
}
2631
```
2732

28-
###Correct:
33+
### Correct
34+
2935
``` PowerShell
3036
$var1 = $null
3137
function Test-NotGlobal ($var1, $var2)

RuleDocumentation/AvoidInvokingEmptyMembers.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
#AvoidInvokingEmptyMembers
1+
# AvoidInvokingEmptyMembers
2+
23
**Severity Level: Warning**
34

4-
##Description
5+
## Description
6+
57
Invoking non-constant members can cause potential bugs. Please double check the syntax to make sure that invoked members are constants.
68

7-
##How to Fix
9+
## How
10+
811
Provide the requested members for a given type or class.
912

10-
##Example
11-
###Wrong:
13+
## Example
14+
15+
### Wrong
16+
1217
``` PowerShell
1318
$MyString = "abc"
1419
$MyString.('len'+'gth')
1520
```
1621

17-
###Correct:
22+
### Correct
23+
1824
``` PowerShell
1925
$MyString = "abc"
2026
$MyString.('length')

RuleDocumentation/AvoidNullOrEmptyHelpMessageAttribute.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
#AvoidNullOrEmtpyHelpMessageAttribute
1+
# AvoidNullOrEmtpyHelpMessageAttribute
2+
23
**Severity Level: Warning**
34

4-
##Description
5+
## Description
6+
57
The value of the `HelpMessage` attribute should not be an empty string or a null value as this causes PowerShell's interpreter to throw an mirror when executing the
68
function or cmdlet.
79

8-
##How to Fix
10+
## How
11+
912
Specify a value for the `HelpMessage` attribute.
1013

11-
##Example
12-
###Wrong:
14+
## Example
15+
16+
### Wrong
17+
1318
``` PowerShell
1419
Function BadFuncEmptyHelpMessageEmpty
1520
{
@@ -45,7 +50,8 @@ Function BadFuncEmptyHelpMessageNoAssignment
4550
}
4651
```
4752

48-
###Correct:
53+
### Correct
54+
4955
``` PowerShell
5056
Function GoodFuncHelpMessage
5157
{

RuleDocumentation/AvoidReservedCharInCmdlet.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
#AvoidReservedCharInCmdlet
1+
# AvoidReservedCharInCmdlet
2+
23
**Severity Level: Error**
34

4-
##Description
5+
## Description
6+
57
You cannot use following reserved characters in a function or cmdlet name as these can cause parsing or runtime errors.
68

79
Reserved Characters include: `#,(){}[]&/\\$^;:\"'<>|?@`*%+=~`
810

9-
##How to Fix
11+
## How
12+
1013
Remove reserved characters from names.
1114

12-
##Example
13-
###Wrong:
15+
## Example
16+
17+
### Wrong
18+
1419
``` PowerShell
1520
function MyFunction[1]
1621
{...}
1722
```
1823

19-
###Correct:
24+
### Correct
25+
2026
``` PowerShell
2127
function MyFunction
2228
{...}

RuleDocumentation/AvoidReservedParams.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
#AvoidReservedParams
1+
# AvoidReservedParams
2+
23
**Severity Level: Error**
34

4-
##Description
5+
## Description
6+
57
You cannot use reserved common parameters in an advanced function.
68

7-
##How to Fix
9+
## How
10+
811
Change the name of the parameter.
912

10-
##Example
11-
###Wrong:
13+
## Example
14+
15+
### Wrong
16+
1217
``` PowerShell
1318
function Test
1419
{
@@ -21,7 +26,8 @@ function Test
2126
}
2227
```
2328

24-
###Correct:
29+
### Correct
30+
2531
``` PowerShell
2632
function Test
2733
{

0 commit comments

Comments
 (0)