Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code indentation #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

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