Skip to content

Commit 59d3d54

Browse files
committed
Add more rule documentations
1 parent 8b3dfdf commit 59d3d54

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#AvoidInvokingEmptyMembers
2+
**Severity Level: Warning**
3+
4+
5+
##Description
6+
7+
Invoking non-constant members would cause potential bugs. Please double check the syntax to make sure members invoked are non-constant.
8+
9+
10+
##How to Fix
11+
12+
To fix a violation of this rule, please provide requested members for given types or classes.
13+
14+
##Example
15+
16+
Wrong:
17+
18+
"abc".('len'+'gth')
19+
20+
Correct:
21+
22+
"abc".('length')
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#AvoidReservedCharInCmdlet
2+
**Severity Level: Error**
3+
4+
5+
##Description
6+
7+
You cannot use following reserved characters in a function name. These characters usually cause a parsing error. Otherwise they will generally cause runtime errors.
8+
#,(){}[]&/\\$^;:\"'<>|?@`*%+=~
9+
10+
11+
##How to Fix
12+
13+
To fix a violation of this rule, please remove reserved characters from your advanced function name.
14+
15+
##Example
16+
17+
Wrong:
18+
19+
function test[1]
20+
{...}
21+
22+
Correct:
23+
24+
function test
25+
{...}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#AvoidReservedParams
2+
**Severity Level: Error**
3+
4+
5+
##Description
6+
7+
You cannot use reserved common parameters in an advanced function. If these parameters are defined by the user, an error generally occurs.
8+
9+
##How to Fix
10+
11+
To fix a violation of this rule, please change the name of your parameter.
12+
13+
##Example
14+
15+
Wrong:
16+
17+
function test
18+
{
19+
20+
[CmdletBinding]
21+
Param($ErrorVariable, $b)
22+
}
23+
24+
Correct:
25+
26+
function test
27+
{
28+
29+
[CmdletBinding]
30+
Param($err, $b)
31+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#AvoidUsingPositionalParameters
2+
**Severity Level: Info**
3+
4+
##Description
5+
6+
To fix a violation of this rule, please use named parameters instead of positional parameters when calling a command.
7+
8+
##How to Fix
9+
10+
To fix a violation of this rule, please use named parameters instead of positional parameters when calling a command.
11+
12+
##Example
13+
Wrong:
14+
15+
Get-ChildItem *.txt
16+
17+
Correct:
18+
19+
Get-Content -Path *.txt

0 commit comments

Comments
 (0)