Skip to content

Commit 296f091

Browse files
committed
Change code formatting
1 parent 0c82a4a commit 296f091

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

CustomizedRuleDocumentation.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This documentation serves as a basic guideline on how to define customized rules
55

66
###Basics
77
1. Function should have comment-based help. Make sure .DESCRIPTION field is there, as it will be consumed as rule description for the customized rule.
8+
```
89
<#
910
.SYNOPSIS
1011
Name of your rule.
@@ -15,30 +16,35 @@ This documentation serves as a basic guideline on how to define customized rules
1516
.OUTPUTS
1617
.NOTES
1718
#>
19+
```
1820

1921
2. Output type should be DiagnosticRecord:
2022
[OutputType([Microsoft.Windows.Powershell.ScriptAnalyzer.Generic.DiagnosticRecord[]])]
2123

2224
3. Make sure the function takes either a Token or an Ast as a parameter
25+
```
2326
Param
2427
(
2528
[Parameter(Mandatory = $true)]
2629
[ValidateNotNullOrEmpty()]
2730
[System.Management.Automation.Language.ScriptBlockAst]
2831
$testAst
2932
)
30-
33+
```
3134
5. DiagnosticRecord should have four properties: Message, Extent, RuleName and Severity
32-
$result = [Microsoft.Windows.Powershell.ScriptAnalyzer.Generic.DiagnosticRecord[]]@{"Message" = "this is help";
33-
"Extent" = $ast.Extent;
34-
"RuleName" = $PSCmdlet.MyInvocation.InvocationName;
35-
"Severity" = "Warning"}
36-
35+
```
36+
$result = [Microsoft.Windows.Powershell.ScriptAnalyzer.Generic.DiagnosticRecord[]]@{"Message" = "This is a sample rule";
37+
"Extent" = $ast.Extent;
38+
"RuleName" = $PSCmdlet.MyInvocation.InvocationName;
39+
"Severity" = "Warning"}
40+
```
3741
6. Make sure you export the function(s) at the end of the script using Export-ModuleMember
42+
```
3843
Export-ModuleMember -Function (FunctionName)
44+
```
3945

4046
###Example
41-
47+
```
4248
<#
4349
.SYNOPSIS
4450
Uses #Requires -RunAsAdministrator instead of your own methods.
@@ -144,5 +150,5 @@ function Measure-RequiresRunAsAdministrator
144150
}
145151
}
146152
}
147-
153+
```
148154
More examples can be found in *Tests\Engine\CommunityRules*

0 commit comments

Comments
 (0)