You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
7
8
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.
11
10
11
+
```powershell
12
+
$hashtable = @{
13
+
property1 = "value"
14
+
anotherProperty = "another value"
15
+
}
12
16
```
13
17
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
16
30
31
+
```powershell
32
+
Rules = @{
33
+
PSAlignAssignmentStatement = @{
34
+
Enable = $true
35
+
CheckHashtable = $true
36
+
}
37
+
}
17
38
```
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