Skip to content

Commit ff12e3a

Browse files
committed
Add rule documentation of the rule UseShouldProcessForStateChangingFunctions
1 parent 763844f commit ff12e3a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#UseShouldProcessForStateChangingFunctions
2+
**Severity Level: Warning**
3+
4+
##Description
5+
6+
Functions that have verbs like New, Start, Stop, Set, Reset that change system state should support 'ShouldProcess'
7+
8+
##How to Fix
9+
10+
To fix a violation of this rule, please add attribute SupportsShouldProcess. eg: [CmdletBinding(SupportsShouldProcess = $true)] to the function.
11+
12+
##Example
13+
14+
Wrong:
15+
```
16+
function Get-ServiceObject
17+
{
18+
[CmdletBinding()]
19+
param ([string]$c)
20+
}
21+
```
22+
23+
Correct:
24+
'''
25+
function Get-ServiceObject
26+
{
27+
[CmdletBinding(SupportsShouldProcess = $true)]
28+
param ([string]$c)
29+
}
30+
'''

0 commit comments

Comments
 (0)