Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Wrong indentation with if+for - missing leading tab #108

Closed
Infocatcher opened this Issue · 2 comments

2 participants

@Infocatcher

Following code

if(options)
    for(var p in options)
        this[p] = options[p];

wrongly becomes

if (options) for (var p in options)
this[p] = options[p];

And should be

if (options) for (var p in options)
    this[p] = options[p];

or like original

if (options)
    for (var p in options)
        this[p] = options[p];
@bitwiseman bitwiseman referenced this issue from a commit
@bitwiseman bitwiseman Add bare if-for test
Closes issue #108
2180f46
@bitwiseman
Owner

This has been fixed and we now have a test to cover this.

// Input 
if (options)
    for (var p in options)
        this[p] = options[p];

// If preserve_newlines == true, the above is unchanged.
// If not, it gets collapsed to one line. 
if (options) for (var p in options) this[p] = options[p];

// Also, when preserving newlines, this:
if (options) for (var p in options) 
this[p] = options[p];

// Becomes this: 
if (options) for (var p in options) 
        this[p] = options[p];

// Why?  Because the child of the for should be indented further than a child of just the if...
if (options) for (var p in options)
        this[p] = options[p];
else
    console.warn('No options found!')

// Not awesome but you're talking about some ugly code anyway.  :)
@bitwiseman bitwiseman closed this
@Infocatcher

Thanks,

if (options) for (var p in options)
        this[p] = options[p];

are better than

if (options) for (var p in options)
this[p] = options[p];

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.