Skip to content

Commit b5afd5d

Browse files
bergmeisterJamesWTruher
authored andcommitted
Make documentation of AvoidUsingPositionalParameters match the implementation (#867)
* Make documentation of AvoidUsingPositionalParameters match the implementation * add more documentation details as suggested in PR comment
1 parent 79fe37f commit b5afd5d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# AvoidUsingPositionalParameters
22

3-
**Severity Level: Warning**
3+
** Severity Level: Information **
44

55
## Description
66

77
When developing PowerShell content that will potentially need to be maintained over time, either by the original author or others, you should use full command names and parameter names.
88

9-
The use of positional parameters can reduce the readability of code and potentially introduce errors.
9+
The use of positional parameters can reduce the readability of code and potentially introduce errors. Furthermore it is possible that future signatures of a Cmdlet could change in a way that would break existing scripts if calls to the Cmdlet rely on the position of the parameters.
10+
11+
For simple Cmdlets with only a few positional parameters, the risk is much smaller and in order for this rule to be not too noisy, this rule gets only triggered when there are 3 or more parameters supplied. A simple example where the risk of using positional parameters is negligible, is e.g. `Test-Path $Path`.
1012

1113
## How
1214

@@ -17,11 +19,11 @@ Use full parameter names when calling commands.
1719
### Wrong
1820

1921
``` PowerShell
20-
Get-ChildItem *.txt
22+
Get-Command Get-ChildItem Microsoft.PowerShell.Management System.Management.Automation.Cmdlet
2123
```
2224

2325
### Correct
2426

2527
``` PowerShell
26-
Get-Content -Path *.txt
28+
Get-Command -Noun Get-ChildItem -Module Microsoft.PowerShell.Management -ParameterType System.Management.Automation.Cmdlet
2729
```

0 commit comments

Comments
 (0)