-
Notifications
You must be signed in to change notification settings - Fork 664
Open
Description
- Code block indentation
If(test-expression){ # 1st/top tier code block; no indentation
If(test-expression){ # 2nd tier code block is indented correctly
$var = "val" # 3rd tier code block is NOT indented correctly
}
$header = @{
'Content-Type'='application/json'
} # why is this closing brace indented twice? It should
# match the margin of the line where the brace started
}
- $null in a test expression.
If ($test1 -eq $null) {
# this is a bad test expression
# it may work but it is considered bad PowerShell syntax
}
ElseIf ($null -eq $test2) {
# this is a good test expression
# if an expression is comparing against a $null value, $null should always be
# on the left side of the comparison
}
- Whitespace
# 'If' statements have no spacing in the syntax...
If($authResult.AccessToken){
}
# ...but 'else' statements do
else {
}
# Some variable/parameter assignments are spaced and others are not
$var = @{ # spaced variable assignment
'Content-Type'='application/json' # unspaced variable assignment
}
The lack of consistency and code etiquette from a Microsoft professional is appalling.
Metadata
Metadata
Assignees
Labels
No labels