Skip to content

Commit 462449b

Browse files
committed
Sync docs edits from docs repo
1 parent f05704d commit 462449b

File tree

7 files changed

+169
-121
lines changed

7 files changed

+169
-121
lines changed

docs/Rules/AlignAssignmentStatement.md

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Align assignment statement
3-
ms.date: 06/28/2023
3+
ms.date: 03/20/2026
44
ms.topic: reference
55
title: AlignAssignmentStatement
66
---
@@ -10,14 +10,13 @@ title: AlignAssignmentStatement
1010

1111
## Description
1212

13-
Consecutive assignment statements are more readable when they're aligned.
14-
Assignments are considered aligned when their `equals` signs line up vertically.
13+
Consecutive assignment statements are more readable when they're aligned. Assignments are considered
14+
aligned when their `equals` signs line up vertically.
1515

16-
This rule looks at the key-value pairs in hashtables (including DSC
17-
configurations) as well as enum definitions.
16+
This rule looks at the key-value pairs in hashtables (including DSC configurations) as well as enum
17+
definitions.
1818

19-
Consider the following example which has a hashtable and enum which are not
20-
aligned.
19+
Consider the following example with a hashtable and enum that isn't aligned.
2120

2221
```powershell
2322
$hashtable = @{
@@ -45,8 +44,8 @@ enum Enum {
4544
}
4645
```
4746

48-
The rule ignores any assignments within hashtables and enums which are on the
49-
same line as others. For example, the rule ignores `$h = @{a = 1; b = 2}`.
47+
The rule ignores any assignments within hashtables and enums which are on the same line as others.
48+
For example, the rule ignores `$h = @{a = 1; b = 2}`.
5049

5150
## Configuration
5251

@@ -71,15 +70,14 @@ Enable or disable the rule during ScriptAnalyzer invocation.
7170

7271
#### CheckHashtable: bool (Default value is `$true`)
7372

74-
Enforce alignment of assignment statements in a hashtable and in a DSC
75-
Configuration. There is only one setting for hashtable and DSC configuration
76-
because the property value pairs in a DSC configuration are parsed as key-value
77-
pairs of a hashtable.
73+
Enforce alignment of assignment statements in a hashtable and in a DSC Configuration. There is only
74+
one setting for hashtable and DSC configuration because the property value pairs in a DSC
75+
configuration are parsed as key-value pairs of a hashtable.
7876

7977
#### AlignHashtableKvpWithInterveningComment: bool (Default value is `$true`)
8078

81-
Include key-value pairs in the alignment that have an intervening comment - that
82-
is to say a comment between the key name and the equals sign.
79+
Include key-value pairs in the alignment that have an intervening comment - that is to say a comment
80+
between the key name and the equals sign.
8381

8482
Consider the following:
8583

@@ -91,8 +89,7 @@ $hashtable = @{
9189
}
9290
```
9391

94-
With this setting disabled, the line with the comment is ignored, and it would
95-
be aligned like so:
92+
With this setting disabled, the line with the comment is ignored, and it would be aligned like so:
9693

9794
```powershell
9895
$hashtable = @{
@@ -118,8 +115,8 @@ Enforce alignment of assignment statements of an Enum definition.
118115

119116
#### AlignEnumMemberWithInterveningComment: bool (Default value is `$true`)
120117

121-
Include enum members in the alignment that have an intervening comment - that
122-
is to say a comment between the member name and the equals sign.
118+
Include enum members in the alignment that have an intervening comment - that is to say a comment
119+
between the member name and the equals sign.
123120

124121
Consider the following:
125122

@@ -131,8 +128,7 @@ enum Enum {
131128
}
132129
```
133130

134-
With this setting disabled, the line with the comment is ignored, and it would
135-
be aligned like so:
131+
With this setting disabled, the line with the comment is ignored, and it would be aligned like so:
136132

137133
```powershell
138134
enum Enum {
@@ -154,9 +150,8 @@ enum Enum {
154150

155151
#### IncludeValuelessEnumMembers: bool (Default value is `$true`)
156152

157-
Include enum members in the alignment that don't have an initial value - that
158-
is to say they don't have an equals sign. Enum's don't need to be given a value
159-
when they're defined.
153+
Include enum members in the alignment that don't have an explicitly assigned value. Enum's don't
154+
need to be given a value when they're defined.
160155

161156
Consider the following:
162157

@@ -168,8 +163,8 @@ enum Enum {
168163
}
169164
```
170165

171-
With this setting disabled the third line which has no value is not considered
172-
when choosing where to align assignments. It would be aligned like so:
166+
With this setting disabled, the third line, which has no value, isn't considered when choosing where
167+
to align assignments. It would be aligned like so:
173168

174169
```powershell
175170
enum Enum {
@@ -179,8 +174,7 @@ enum Enum {
179174
}
180175
```
181176

182-
With it enabled, the valueless member is included in alignment as if it had a
183-
value:
177+
With it enabled, the valueless member is included in alignment as if it had a value:
184178

185179
```powershell
186180
enum Enum {

docs/Rules/AvoidLongLines.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Avoid long lines
3-
ms.date: 04/29/2025
3+
ms.date: 03/20/2026
44
ms.topic: reference
55
title: AvoidLongLines
66
---
@@ -10,8 +10,8 @@ title: AvoidLongLines
1010

1111
## Description
1212

13-
The length of lines, including leading spaces (indentation), should be less than the configured number
14-
of characters. The default length is 120 characters.
13+
The length of lines, including leading spaces (indentation), should be less than the configured
14+
number of characters. The default length is 120 characters.
1515

1616
> [!NOTE]
1717
> This rule isn't enabled by default. The user needs to enable it through settings.

docs/Rules/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: List of PSScriptAnalyzer rules
3-
ms.date: 03/27/2024
3+
ms.date: 03/20/2026
44
ms.topic: reference
55
title: List of PSScriptAnalyzer rules
66
---

docs/Rules/UseConsistentParameterSetName.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Use consistent parameter set names and proper parameter set configuration.
3-
ms.date: 08/19/2025
3+
ms.date: 03/20/2026
44
ms.topic: reference
55
title: UseConsistentParameterSetName
66
---
@@ -11,18 +11,25 @@ title: UseConsistentParameterSetName
1111

1212
## Description
1313

14-
Parameter set names in PowerShell are case-sensitive, unlike most other PowerShell elements. This rule ensures consistent casing and proper configuration of parameter sets to avoid runtime errors and improve code clarity.
14+
Parameter set names in PowerShell are case-sensitive, unlike most other PowerShell elements. This
15+
rule ensures consistent casing and proper configuration of parameter sets to avoid runtime errors
16+
and improve code clarity.
1517

1618
The rule performs five different checks:
1719

18-
1. **Missing DefaultParameterSetName** - Warns when parameter sets are used but no default is specified
19-
2. **Multiple parameter declarations** - Detects when a parameter is declared multiple times in the same parameter set. This is ultimately a runtime exception - this check helps catch it sooner.
20-
3. **Case mismatch between DefaultParameterSetName and ParameterSetName** - Ensures consistent casing
21-
4. **Case mismatch between different ParameterSetName values** - Ensures all references to the same parameter set use identical casing
22-
5. **Parameter set names containing newlines** - Warns against using newline characters in parameter set names
20+
1. **Missing DefaultParameterSetName** - Warns when parameter sets are used but no default is
21+
specified
22+
1. **Multiple parameter declarations** - Detects when a parameter is declared multiple times in the
23+
same parameter set. This is ultimately a runtime exception - this check helps catch it sooner.
24+
1. **Case mismatch between DefaultParameterSetName and ParameterSetName** - Ensures consistent
25+
casing
26+
1. **Case mismatch between different ParameterSetName values** - Ensures all references to the same
27+
parameter set use identical casing
28+
1. **Parameter set names containing newlines** - Warns against using newline characters in parameter
29+
set names
2330

2431
> [!NOTE]
25-
> This rule is not enabled by default. The user needs to enable it through settings.
32+
> This rule isn't enabled by default. The user needs to enable it through settings.
2633
2734
## How
2835

@@ -43,7 +50,7 @@ function Get-Data {
4350
param(
4451
[Parameter(ParameterSetName='ByName')]
4552
[string]$Name,
46-
53+
4754
[Parameter(ParameterSetName='ByID')]
4855
[int]$ID
4956
)
@@ -55,7 +62,7 @@ function Get-Data {
5562
param(
5663
[Parameter(ParameterSetName='byname')]
5764
[string]$Name,
58-
65+
5966
[Parameter(ParameterSetName='ByID')]
6067
[int]$ID
6168
)
@@ -67,7 +74,7 @@ function Get-Data {
6774
param(
6875
[Parameter(ParameterSetName='ByName')]
6976
[string]$Name,
70-
77+
7178
[Parameter(ParameterSetName='byname')]
7279
[string]$DisplayName
7380
)
@@ -100,11 +107,11 @@ function Get-Data {
100107
param(
101108
[Parameter(ParameterSetName='ByName', Mandatory)]
102109
[string]$Name,
103-
110+
104111
[Parameter(ParameterSetName='ByName')]
105112
[Parameter(ParameterSetName='ByID')]
106113
[string]$ComputerName,
107-
114+
108115
[Parameter(ParameterSetName='ByID', Mandatory)]
109116
[int]$ID
110117
)
@@ -129,7 +136,9 @@ Rules = @{
129136

130137
## Notes
131138

132-
- Parameter set names are case-sensitive in PowerShell, making this different from most other PowerShell elements
139+
- Parameter set names are case-sensitive in PowerShell, making this different from most other
140+
PowerShell elements
133141
- The first occurrence of a parameter set name in your code is treated as the canonical casing
134-
- Parameters without [Parameter()] attributes are automatically part of all parameter sets
135-
- It's a PowerShell best practice to always specify a DefaultParameterSetName when using parameter sets
142+
- Parameters without `[Parameter()]` attributes are automatically part of all parameter sets
143+
- It's a PowerShell best practice to always specify a `DefaultParameterSetName` when using parameter
144+
sets

docs/Rules/UseConsistentParametersKind.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
1+
description: Use the same pattern when defining parameters.
2+
ms.date: 03/20/2026
3+
ms.topic: reference
4+
title: UseConsistentParametersKind
5+
---
16
# UseConsistentParametersKind
27

38
**Severity Level: Warning**
49

510
## Description
611

7-
All functions should have same parameters definition kind specified in the rule.
8-
Possible kinds are:
9-
1. `Inline`, i.e.:
10-
```PowerShell
11-
function f([Parameter()]$FirstParam) {
12-
return
13-
}
14-
```
15-
2. `ParamBlock`, i.e.:
16-
```PowerShell
17-
function f {
18-
param([Parameter()]$FirstParam)
19-
return
20-
}
21-
```
12+
All functions should use the same pattern when defining parameters. Possible pattern types are:
13+
14+
1. `Inline`
15+
16+
```powershell
17+
function f([Parameter()]$FirstParam) {
18+
return
19+
}
20+
```
21+
22+
1. `ParamBlock`
2223

23-
* For information: in simple scenarios both function definitions above may be considered as equal. Using this rule as-is is more for consistent code-style than functional, but it can be useful in combination with other rules.
24+
```powershell
25+
function f {
26+
param([Parameter()]$FirstParam)
27+
return
28+
}
29+
```
30+
31+
In simple scenarios, both function definitions shown are considered to be equal. The purpose of this
32+
rule is to enforce consistent code style across the codebase.
2433

2534
## How to Fix
2635

2736
Rewrite function so it defines parameters as specified in the rule
2837

2938
## Example
3039

31-
### When the rule sets parameters definition kind to 'Inline':
32-
```PowerShell
40+
When the rule sets parameters definition kind to `Inline`:
41+
42+
```powershell
3343
# Correct
3444
function f([Parameter()]$FirstParam) {
3545
return
@@ -42,8 +52,9 @@ function g {
4252
}
4353
```
4454

45-
### When the rule sets parameters definition kind to 'ParamBlock':
46-
```PowerShell
55+
When the rule sets parameters definition kind to `ParamBlock`:
56+
57+
```powershell
4758
# Inorrect
4859
function f([Parameter()]$FirstParam) {
4960
return

0 commit comments

Comments
 (0)