Skip to content

Commit 8f20c98

Browse files
MWL88JamesWTruher
authored andcommitted
Fix Markdown linting warnings so it now renders in GitHub (#898)
1 parent de28e4f commit 8f20c98

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

ScriptRuleDocumentation.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
##Documentation for Customized Rules in PowerShell Scripts
2-
PSScriptAnalyzer uses MEF(Managed Extensibility Framework) to import all rules defined in the assembly. It can also consume rules written in PowerShell scripts.
1+
## Documentation for Customized Rules in PowerShell Scripts
2+
3+
PSScriptAnalyzer uses MEF(Managed Extensibility Framework) to import all rules defined in the assembly. It can also consume rules written in PowerShell scripts.
34

45
When calling Invoke-ScriptAnalyzer, users can specify custom rules using the parameter `CustomizedRulePath`.
56

67
The purpose of this documentation is to server as a basic guide on creating your own customized rules.
78

8-
###Basics
9+
### Basics
10+
911
- Functions should have comment-based help. Make sure .DESCRIPTION field is there, as it will be consumed as rule description for the customized rule.
12+
1013
``` PowerShell
1114
<#
1215
.SYNOPSIS
@@ -21,11 +24,13 @@ The purpose of this documentation is to server as a basic guide on creating your
2124
```
2225

2326
- Output type should be DiagnosticRecord:
27+
2428
``` PowerShell
2529
[OutputType([Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord[]])]
2630
```
2731

2832
- Make sure each function takes either a Token or an Ast as a parameter
33+
2934
``` PowerShell
3035
Param
3136
(
@@ -37,6 +42,7 @@ Param
3742
```
3843

3944
- DiagnosticRecord should have four properties: Message, Extent, RuleName and Severity
45+
4046
``` PowerShell
4147
$result = [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord[]]@{
4248
"Message" = "This is a sample rule"
@@ -47,18 +53,20 @@ $result = [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord[
4753
```
4854

4955
- Make sure you export the function(s) at the end of the script using Export-ModuleMember
56+
5057
``` PowerShell
5158
Export-ModuleMember -Function (FunctionName)
5259
```
5360

54-
###Example
61+
### Example
62+
5563
``` PowerShell
5664
<#
5765
.SYNOPSIS
5866
Uses #Requires -RunAsAdministrator instead of your own methods.
5967
.DESCRIPTION
60-
The #Requires statement prevents a script from running unless the Windows PowerShell version, modules, snap-ins, and module and snap-in version prerequisites are met.
61-
From Windows PowerShell 4.0, the #Requires statement let script developers require that sessions be run with elevated user rights (run as Administrator).
68+
The #Requires statement prevents a script from running unless the Windows PowerShell version, modules, snap-ins, and module and snap-in version prerequisites are met.
69+
From Windows PowerShell 4.0, the #Requires statement let script developers require that sessions be run with elevated user rights (run as Administrator).
6270
Script developers does not need to write their own methods any more.
6371
To fix a violation of this rule, please consider to use #Requires -RunAsAdministrator instead of your own methods.
6472
.EXAMPLE
@@ -123,12 +131,12 @@ function Measure-RequiresRunAsAdministrator
123131
}
124132
#endregion
125133
#region Finds ASTs that match the predicates.
126-
134+
127135
[System.Management.Automation.Language.Ast[]]$methodAst = $ScriptBlockAst.FindAll($predicate1, $true)
128136
[System.Management.Automation.Language.Ast[]]$assignmentAst = $ScriptBlockAst.FindAll($predicate2, $true)
129137
if ($null -ne $ScriptBlockAst.ScriptRequirements)
130138
{
131-
if ((!$ScriptBlockAst.ScriptRequirements.IsElevationRequired) -and
139+
if ((!$ScriptBlockAst.ScriptRequirements.IsElevationRequired) -and
132140
($methodAst.Count -ne 0) -and ($assignmentAst.Count -ne 0))
133141
{
134142
$result = [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord]@{
@@ -137,7 +145,7 @@ function Measure-RequiresRunAsAdministrator
137145
'RuleName' = $PSCmdlet.MyInvocation.InvocationName
138146
'Severity' = 'Information'
139147
}
140-
$results += $result
148+
$results += $result
141149
}
142150
}
143151
else
@@ -150,11 +158,11 @@ function Measure-RequiresRunAsAdministrator
150158
'RuleName' = $PSCmdlet.MyInvocation.InvocationName
151159
'Severity' = 'Information'
152160
}
153-
$results += $result
154-
}
161+
$results += $result
162+
}
155163
}
156164
return $results
157-
#endregion
165+
#endregion
158166
}
159167
catch
160168
{

0 commit comments

Comments
 (0)