Skip to content

Commit 40e21f3

Browse files
author
Kapil Borle
committed
Add documentation for AlignAssignmentStatement rule
1 parent 1b75112 commit 40e21f3

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed
Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
11
# AlignAssignmentStatement
2+
23
**Severity Level: Warning**
34

45
## Description
56

6-
## How to Fix
7+
Consecutive assignment statements are more readable if they are aligned. By aligned, we imply that the `equal` sign for all the assignment statements should be in the same column.
78

8-
## Example
9-
### Wrong:
10-
```PowerShell
9+
The rule looks for key (property) value pairs in a hashtable (DSC configuration) to check if they are aligned or not. Consider the following example in which the key value pairs are not aligned.
1110

11+
```powershell
12+
$hashtable = @{
13+
property1 = "value"
14+
anotherProperty = "another value"
15+
}
1216
```
1317

14-
### Correct:
15-
```PowerShell
18+
Alignment in this case would look like the following.
19+
20+
```powershell
21+
$hashtable = @{
22+
property1 = "value"
23+
anotherProperty = "another value"
24+
}
25+
```
26+
27+
The rule will ignore hashtables in which the assignment statements are on the same line. For example, the rule will ignore `$h = {a = 1; b = 2}`.
28+
29+
## Configuration
1630

31+
```powershell
32+
Rules = @{
33+
PSAlignAssignmentStatement = @{
34+
Enable = $true
35+
CheckHashtable = $true
36+
}
37+
}
1738
```
39+
40+
### Parameters
41+
42+
#### Enable: bool (Default value is `$false`)
43+
44+
Enable or disable the rule during ScriptAnalyzer invocation.
45+
46+
#### CheckHashtable: bool (Default value is `$false`)
47+
48+
Enforce alignment of assignment statements in a hashtable and in a DSC Configuration. There is only one switch for hasthable and DSC configuration because the property value pairs in a DSC configuration are parsed as key value pairs of a hashtable.

0 commit comments

Comments
 (0)