Skip to content

Ugly Code #282

@Kor1134

Description

@Kor1134
  1. 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
}
  1. $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
}
  1. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions