Skip to content

Commit 561f108

Browse files
committed
Add more rule documentations
1 parent d0e217f commit 561f108

File tree

6 files changed

+179
-0
lines changed

6 files changed

+179
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#MissingModuleManifestField
2+
**Severity Level: Warning**
3+
4+
5+
##Description
6+
7+
Some fields of the module manifest (such as ModuleVersion) are required.
8+
9+
##How to Fix
10+
11+
Please consider adding the missing fields to the manifest.
12+
13+
##Example
14+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#PossibleIncorrectComparisonWithNull
2+
**Severity Level: Warning**
3+
4+
5+
##Description
6+
7+
Checks that $null is on the left side of any equaltiy comparisons (eq, ne, ceq, cne, ieq, ine). When there is an array on the left side of a null equality comparison, PowerShell will check for a $null IN the array rather than if the array is null. If the two sides of the comaprision are switched this is fixed. Therefore, $null should always be on the left side of equality comparisons just in case.
8+
9+
##How to Fix
10+
11+
Please consider moving null on the left side of the comparison.
12+
##Example
13+
14+
Wrong:
15+
16+
function CompareWithNull
17+
{
18+
if ($DebugPreference -eq $null)
19+
{
20+
}
21+
}
22+
23+
Correct:
24+
25+
function CompareWithNull
26+
{
27+
if ($null -eq $DebugPreference)
28+
{
29+
}
30+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#ProvideCommentHelp
2+
**Severity Level: Info**
3+
4+
5+
##Description
6+
7+
Checks that all cmdlets have a help comment. This rule only checks existence. It does not check the content of the comment.
8+
9+
10+
##How to Fix
11+
12+
Please consider adding help comment for each cmdlet.
13+
14+
##Example
15+
16+
Wrong:
17+
18+
function Verb-Files
19+
{
20+
[CmdletBinding(DefaultParameterSetName='Parameter Set 1',
21+
SupportsShouldProcess=$true,
22+
PositionalBinding=$false,
23+
HelpUri = 'http://www.microsoft.com/',
24+
ConfirmImpact='Medium')]
25+
[Alias()]
26+
[OutputType([String])]
27+
Param
28+
(
29+
...
30+
)
31+
32+
}
33+
34+
Right:
35+
36+
<#
37+
.Synopsis
38+
Short description
39+
.DESCRIPTION
40+
Long description
41+
.EXAMPLE
42+
Example of how to use this cmdlet
43+
.EXAMPLE
44+
Another example of how to use this cmdlet
45+
.INPUTS
46+
Inputs to this cmdlet (if any)
47+
.OUTPUTS
48+
Output from this cmdlet (if any)
49+
.NOTES
50+
General notes
51+
.COMPONENT
52+
The component this cmdlet belongs to
53+
.ROLE
54+
The role this cmdlet belongs to
55+
.FUNCTIONALITY
56+
The functionality that best describes this cmdlet
57+
#>
58+
function Get-File
59+
{
60+
[CmdletBinding(DefaultParameterSetName='Parameter Set 1',
61+
SupportsShouldProcess=$true,
62+
PositionalBinding=$false,
63+
HelpUri = 'http://www.microsoft.com/',
64+
ConfirmImpact='Medium')]
65+
[Alias()]
66+
[OutputType([String])]
67+
Param
68+
(
69+
...
70+
)
71+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ProvideVerboseMessage
2+
**Severity Level: Warning**
3+
4+
5+
##Description
6+
7+
Checks that Write-Verbose is called at least once in every cmdlet or script. This is in line with the PowerShell best practices.
8+
9+
##How to Fix
10+
11+
Please consider adding Write-Verbose in each cmdlet.
12+
13+
##Example
14+

RuleDocumentation/UseApprovedVerbs.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#UseApprovedVerbs
2+
**Severity Level: Warning**
3+
4+
5+
##Description
6+
7+
All defined cmdlets must use approved verbs. This is in line with PowerShell's best practices.
8+
9+
##How to Fix
10+
11+
Please consider using full cmdlet name instead of alias.
12+
13+
##Example
14+
15+
Wrong:
16+
17+
function Change-Item
18+
{
19+
...
20+
}
21+
22+
Correct:
23+
24+
function Update-Item
25+
{
26+
...
27+
}
28+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#UseCmdletCorrectly
2+
**Severity Level: Error**
3+
4+
5+
##Description
6+
7+
Cmdlets must be invoked with the correct syntax and parameters. For example, calling Set-Date with no parameters would be triggered by this rule since it has a required date parameter.
8+
9+
##How to Fix
10+
11+
To fix a violation of this rule, please use mandatory parameters when calling cmdlets.
12+
13+
##Example
14+
15+
Wrong:
16+
17+
set-date
18+
19+
Correct:
20+
21+
$t = get-date
22+
set-date -date $t

0 commit comments

Comments
 (0)