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

Already on GitHub? Sign in to your account

If pairing brackets are not in same line, then make sure the opening bracket end is last character, and closing bracket is the first character. #190

Closed
shobhitg opened this Issue Jan 17, 2014 · 6 comments

Comments

Projects
None yet
6 participants

Its hard to explain in words, but here I try...

Here is the example:

This should be invalid:

if (x < 0) { x++;
    func1 ( foo );   // this should be okay
    func2 ( foo,
            bar
    );
} else { x--;
}

This should be valid:

if (x < 0) {
    x++;
    func1 ( foo );
    func2 (
        foo,
        bar
    );
} else {
    x--;
}

If the pair of brackets are in same line, then everything is fine.

If the pair of brackets are not in same line: then the opening brackets should be the last character in its line; and the closing bracket should be the first character in its line.

Same concept applies for all types of brackets.... i.e. () {} []

Owner

mdevils commented Jan 20, 2014

Well. This rule we can accept. Feel free to make a pull-request on this.

Contributor

am11 commented Feb 4, 2014

Another flavor of this style may be a comma-first conjugate:

if (x < 0) {
    x++;
    func1 ( foo );
    func2 (
        foo
      , bar
    );
} else {
    x--;
}

👍

Contributor

mikesherov commented Nov 28, 2014

@am11 @NickHeiner @shobhitg would you like to try implementing this rule?

@mikesherov mikesherov added this to the 1.10 milestone Nov 28, 2014

Contributor

am11 commented Nov 28, 2014

@mikesherov, I will give it a try. :)

Seperately, would it make sense to rename the rules, where if and else with single statements are allowed to drop curlies and similar mustache-related peculiar styling rules be named after K&R (indentation styling)? Source: http://en.wikipedia.org/wiki/Indent_style#K.26R_style.

@markelog markelog removed this from the 1.10 milestone Jan 13, 2015

@markelog markelog added the orphaned label Jan 20, 2015

Owner

markelog commented Jan 20, 2015

This issue has been open more than a month without supported PR for it.

Unfortunately, we don't have the resources to implement rules that could not be included in any of the supported presets (if it could be, please point that out).

However, if you or anybody else submit PR for it, we will gladly consider it.

@markelog markelog closed this Jan 20, 2015

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