Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Code formatting: newlines before and after if statement block #345

Open
SSvilen opened this issue Aug 23, 2019 · 1 comment
Open

Code formatting: newlines before and after if statement block #345

SSvilen opened this issue Aug 23, 2019 · 1 comment
Labels
enhancement The issue is an enhancement request.

Comments

@SSvilen
Copy link
Contributor

SSvilen commented Aug 23, 2019

Hello,

Is the standard for DSC code to have a newline before and after if/ if else statement block?
This is not how I write my code and often I need to reformat it to get my PR approved.
If it is a standard, then I could do a custom PSScriptAnalyzerRule for that.

@johlju
Copy link
Contributor

johlju commented Aug 24, 2019

I like to have air in the code so it easier for new contributors to read the code, it is easier for the eyes to see blocks, and those blociks are written the same throughout a repo. Most code is written with air, but there are no specific guideline around it (see https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md#whitespace). But I love to see this as a guideline and a new custom rule (and more custom rules for the entire style guideline).

So this

$something = $true
if ($something)
{
}
if ()
{
}

I would rather see written as

$something = $true

if ($something)
{
}

if ()
{
}

With the exception of the previous line starts with an open brace. I like to see this as valid.

$something = $true

try
{
    if ($something)
    {
    }
}

@PlagueHO PlagueHO added the enhancement The issue is an enhancement request. label Sep 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement The issue is an enhancement request.
Projects
None yet
Development

No branches or pull requests

3 participants