Skip to content

Commit 995fb21

Browse files
committed
Merge pull request #16 from PowerShell/yutingc-patch-1
Update cmdlet names and parameters in rule documentation
2 parents a2ef243 + 2bbe94e commit 995fb21

15 files changed

+87
-94
lines changed

RuleDocumentation/AvoidAlias.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ Please consider using full cmdlet name instead of alias.
1212

1313
##Example
1414

15-
Wrong: gps | where-object {$_.WorkingSet -gt 20000000}
15+
Wrong: gps | Where-Object {$_.WorkingSet -gt 20000000}
1616

17-
Correct: get-process | where-object {$_.WorkingSet -gt 20000000}
17+
Correct: Get-Process | Where-Object {$_.WorkingSet -gt 20000000}

RuleDocumentation/AvoidDefaultTrueValueSwitchParameter.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Wrong:
1919
( …
2020
$Param1,
2121
[switch]
22-
$switch=$true
22+
$Switch=$True
2323
)
2424

2525
Correct:
@@ -28,5 +28,5 @@ Correct:
2828
( …
2929
$Param1,
3030
[switch]
31-
$switch=$false
31+
$Switch=$False
3232
)

RuleDocumentation/AvoidGlobalVars.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Wrong:
1515
$Global:var1 = $null
1616
function NotGlobal ($var)
1717
{
18-
$a = $var + $var1
18+
$a = $var + $var1
1919
}
2020

2121
Correct:
2222

2323
$Global:var1 = $null
24-
function NotGlobal ($var1,$var2)
24+
function NotGlobal ($var1, $var2)
2525
{
26-
$a = $var1 + $var2
26+
$a = $var1 + $var2
2727
}

RuleDocumentation/AvoidReservedCharInCmdlet.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ To fix a violation of this rule, please remove reserved characters from your adv
1616

1717
Wrong:
1818

19-
function test[1]
19+
function Test[1]
2020
{...}
2121

2222
Correct:
2323

24-
function test
25-
{...}
24+
function Test
25+
{...}

RuleDocumentation/AvoidReservedParams.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ To fix a violation of this rule, please change the name of your parameter.
1313
##Example
1414

1515
Wrong:
16-
17-
function test
16+
```
17+
function Test
1818
{
1919
[CmdletBinding]
2020
Param($ErrorVariable, $b)
2121
}
22+
```
2223

2324
Correct:
24-
25-
function test
25+
```
26+
function Test
2627
{
2728
[CmdletBinding]
2829
Param($err, $b)
2930
}
31+
```

RuleDocumentation/AvoidShouldContinueWithoutForce.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Wrong:
2121
HelpUri = 'http://www.microsoft.com/',
2222
ConfirmImpact='Medium')]
2323
[Alias()]
24-
[OutputType([String])]
24+
[OutputType([string])]
2525
Param
2626
(
2727
# Param1 help description
@@ -50,7 +50,7 @@ Wrong:
5050
[Parameter(ParameterSetName='Another Parameter Set')]
5151
[ValidatePattern("[a-z]*")]
5252
[ValidateLength(0,15)]
53-
[String]
53+
[string]
5454
$Param3
5555
)
5656

@@ -79,7 +79,7 @@ Correct:
7979
HelpUri = 'http://www.microsoft.com/',
8080
ConfirmImpact='Medium')]
8181
[Alias()]
82-
[OutputType([String])]
82+
[OutputType([string])]
8383
Param
8484
(
8585
# Param1 help description
@@ -110,7 +110,7 @@ Correct:
110110
[Parameter(ParameterSetName='Another Parameter Set')]
111111
[ValidatePattern("[a-z]*")]
112112
[ValidateLength(0,15)]
113-
[String]
113+
[string]
114114
$Param3,
115115
[bool]
116116
$Force

RuleDocumentation/AvoidTrapStatement.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ To fix a violation of this rule, please remove Trap statements and use try-catch
1313
##Example
1414

1515
Wrong:
16-
16+
```
1717
function TrapTest
1818
{
1919
trap {"Error found: $_"}
2020
}
21-
21+
```
2222
Correct:
23-
23+
```
2424
function TrapTest
2525
{
2626
try
2727
{
2828
$a = New-Object "dafdf"
29-
$a | get-member
29+
$a | Get-Member
3030
}
3131
catch [System.Exception]
3232
{
@@ -36,4 +36,5 @@ Correct:
3636
{
3737
"End the script"
3838
}
39-
}
39+
}
40+
```

RuleDocumentation/AvoidUsingInvokeExpression.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ To fix a violation of this rule, please remove Invoke-Expression from script and
1515

1616
Wrong:
1717

18-
Invoke-Expression "get-process"
18+
Invoke-Expression "Get-Process"
1919

2020
Correct:
2121

22-
Get-process
22+
Get-Process

RuleDocumentation/AvoidUsingPlainTextForPassword.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To fix a violation of this rule, please use SecurityString as the type of passwo
1313
##Example
1414

1515
Wrong:
16-
16+
```
1717
function Verb-Noun
1818
{
1919
[CmdletBinding()]
@@ -29,28 +29,29 @@ Wrong:
2929
# Param2 help description
3030
[int]
3131
$Param2,
32-
[securestring]
32+
[SecureString]
3333
$Password,
3434
[System.Security.SecureString]
35-
$pass,
36-
[securestring[]]
37-
$passwords,
38-
$passphrases,
39-
$passwordparam
35+
$Pass,
36+
[SecureString[]]
37+
$Passwords,
38+
$Passphrases,
39+
$Passwordparam
4040
)
4141
}
4242
43-
function TestFunction($password, [System.Security.SecureString[]]passphrases, [string]$passThru){
43+
function TestFunction($password, [System.Security.SecureString[]]passphrases, [String]$passThru){
4444
}
45-
45+
```
4646

4747
Correct:
4848

49+
```
4950
function Test-Script
5051
{
5152
[CmdletBinding()]
5253
[Alias()]
53-
[OutputType([int])]
54+
[OutputType([Int])]
5455
Param
5556
(
5657
# Param1 help description
@@ -61,21 +62,22 @@ Correct:
6162
# Param2 help description
6263
[int]
6364
$Param2,
64-
[securestring]
65+
[SecureString]
6566
$Password,
6667
[System.Security.SecureString]
67-
$pass,
68-
[securestring[]]
69-
$passwords,
70-
[securestring]
71-
$passphrases,
72-
[securestring]
73-
$passwordparam,
74-
[string]
75-
$PassThru
68+
$Pass,
69+
[SecureString[]]
70+
$Passwords,
71+
[SecureString]
72+
$Passphrases,
73+
[SecureString]
74+
$PasswordParam,
75+
[string]
76+
$PassThru
7677
)
7778
...
7879
}
7980
80-
function TestFunction([securestring]$password, [System.Security.SecureString[]]$passphrases, [securestring[]]$passes){
81-
}
81+
function TestFunction([SecureString]$Password, [System.Security.SecureString[]]$Passphrases, [SecureString[]]$passes){
82+
}
83+
```

RuleDocumentation/AvoidUsingUsernameAndPasswordParams

Lines changed: 0 additions & 30 deletions
This file was deleted.

RuleDocumentation/AvoidUsingUsernameAndPasswordParams.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ To fix a violation of this rule, please pass username and password as a PSCreden
1313
##Example
1414

1515
Wrong:
16-
17-
[int]
16+
```
17+
[int]
1818
$Param2,
19-
[securestring]
19+
[SecureString]
2020
$Password,
2121
[string]
22-
$username
22+
$Username
23+
```
2324

2425
Correct:
25-
26-
function MyFunction3 ([PSCredential]$username, $passwords)
27-
{
28-
}
26+
```
27+
function MyFunction3 ([PSCredential]$Username, $Passwords)
28+
{
29+
}
30+
```

RuleDocumentation/ProvideCommentHelp.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Wrong:
2323
HelpUri = 'http://www.microsoft.com/',
2424
ConfirmImpact='Medium')]
2525
[Alias()]
26-
[OutputType([String])]
26+
[OutputType([string])]
2727
Param
2828
(
2929
...
@@ -63,9 +63,9 @@ Right:
6363
HelpUri = 'http://www.microsoft.com/',
6464
ConfirmImpact='Medium')]
6565
[Alias()]
66-
[OutputType([String])]
66+
[OutputType([string])]
6767
Param
6868
(
6969
...
7070
)
71-
}
71+
}

RuleDocumentation/ProvideVerboseMessage.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,20 @@ Checks that Write-Verbose is called at least once in every cmdlet or script. Thi
1111
Please consider adding Write-Verbose in each cmdlet.
1212

1313
##Example
14+
Correct
15+
```
16+
Function TestFunction1
17+
{
18+
[cmdletbinding()]
19+
Param()
20+
Write-Verbose "Verbose output"
1421
22+
}
23+
24+
Function TestFunction2
25+
{
26+
[cmdletbinding()]
27+
Param()
28+
Write-Verbose "Verbose output"
29+
}
30+
```

RuleDocumentation/UseCmdletCorrectly.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ To fix a violation of this rule, please use mandatory parameters when calling cm
1414

1515
Wrong:
1616

17-
set-date
17+
Set-Date
1818

1919
Correct:
2020

21-
$t = get-date
22-
set-date -date $t
21+
$date = Get-Date
22+
Set-Date -Date $t

RuleDocumentation/UsePSCredentialType.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ Please change the parameter type to be PSCredential.
1414

1515
Wrong:
1616

17-
function Credential([string]$credential)
17+
function Credential([String]$Credential)
1818
{
1919
...
2020
}
2121

2222
Correct:
2323

24-
function Credential([PSCredential]$credential)
24+
function Credential([PSCredential]$Credential)
2525
{
2626
...
27-
}
27+
}

0 commit comments

Comments
 (0)