Skip to content

Commit da59807

Browse files
Fix errors in ShouldProcess rule document (#1766)
* Fix ShouldProcess examples * Fix Severity of ShouldProcess to Warning * Add Get-Help * Update links * Copy example from Docs repo * Update ShouldProcess.md Co-authored-by: Sean Wheeler <[email protected]>
1 parent 525a9c6 commit da59807

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

docs/Rules/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The PSScriptAnalyzer contains the following rule definitions.
5555
| [ReservedCmdletChar](./ReservedCmdletChar.md) | Error | Yes | |
5656
| [ReservedParams](./ReservedParams.md) | Error | Yes | |
5757
| [ReviewUnusedParameter](./ReviewUnusedParameter.md) | Warning | Yes | |
58-
| [ShouldProcess](./ShouldProcess.md) | Error | Yes | |
58+
| [ShouldProcess](./ShouldProcess.md) | Warning | Yes | |
5959
| [UseApprovedVerbs](./UseApprovedVerbs.md) | Warning | Yes | |
6060
| [UseBOMForUnicodeEncodedFile](./UseBOMForUnicodeEncodedFile.md) | Warning | Yes | |
6161
| [UseCmdletCorrectly](./UseCmdletCorrectly.md) | Warning | Yes | |

docs/Rules/ShouldProcess.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ title: ShouldProcess
1414
If a cmdlet declares the `SupportsShouldProcess` attribute, then it should also call
1515
`ShouldProcess`. A violation is any function which either declares `SupportsShouldProcess` attribute
1616
but makes no calls to `ShouldProcess` or it calls `ShouldProcess` but does not declare
17-
`SupportsShouldProcess`
17+
`SupportsShouldProcess`.
1818

1919
For more information, see the following articles:
2020

@@ -26,7 +26,7 @@ For more information, see the following articles:
2626

2727
To fix a violation of this rule, please call `ShouldProcess` method when a cmdlet declares
2828
`SupportsShouldProcess` attribute. Or please add `SupportsShouldProcess` attribute argument when
29-
calling `ShouldProcess`
29+
calling `ShouldProcess`.
3030

3131
## Example
3232

@@ -66,10 +66,5 @@ function Set-File
6666
{
6767
$Content | Out-File -FilePath $Path
6868
}
69-
else
70-
{
71-
# Code that should be processed if doing a WhatIf operation
72-
# Must NOT change anything outside of the function / script
73-
}
7469
}
7570
```

0 commit comments

Comments
 (0)