DscResource.Tests icon indicating copy to clipboard operation
DscResource.Tests copied to clipboard

Code formatting: newlines before and after if statement block

Open SSvilen opened this issue 5 years ago • 1 comments

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.

SSvilen avatar Aug 23 '19 19:08 SSvilen

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)
    {
    }
}

johlju avatar Aug 24 '19 14:08 johlju