Skip to content

Conversation

@vlariono
Copy link

@vlariono vlariono commented Dec 4, 2016

Added code indentation for other types of enclosures, like @(), $(), (), []. It should make code easier for reading.
For example the following flat code:

function Test{
param(
[parameter(Position = 0, 
Mandatory = $false, 
ValueFromPipeline=$true)]
[string]
$Path
)

#array
$a=@( 'this is first string',
'this is second string',
'this is third string'
)

#hash array
$h=@{ 'First' = 'String1'
'Second' = 'String2'
'Third' = 'String3'
}

#script block
$s={
"Hi there"
}

#Expression
$e=$("Here is some"
"expression"
)
}

Original formatting:

function Test{
    param(
    [parameter(Position = 0, 
    Mandatory = $false, 
    ValueFromPipeline=$true)]
    [string]
    $Path
    )
    
    #array
    $a=@( 'this is first string',
    'this is second string',
    'this is third string'
    )
    
    #hash array
    $h=@{ 'First' = 'String1'
        'Second' = 'String2'
        'Third' = 'String3'
    }
    
    #script block
    $s={
        "Hi there"
    }
    
    #Expression
    $e=$("Here is some"
    "expression"
    )
}

Param block, expression and array is still flat

Modified formatting:

function Test{
    param(
        [parameter(Position = 0, 
                Mandatory = $false, 
                ValueFromPipeline=$true)]
        [string]
        $Path
    )
    
    #array
    $a=@( 'this is first string',
        'this is second string',
        'this is third string'
    )
    
    #hash array
    $h=@{ 'First' = 'String1'
        'Second' = 'String2'
        'Third' = 'String3'
    }
    
    #script block
    $s={
        "Hi there"
    }
    
    #Expression
    $e=$("Here is some"
        "expression"
    )
}

Param block, expression and arrays are different. It looks like more natural formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant