Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Allow to always use blocks for if/while/for/do statements?

Hi all,

Since no one complained, as announced before, I've changed the wiki [1]. 

The new coding guideline regarding the braces is (quote from [1]):

"
Starting with 3.7.0 braces are mandatory independently on the number of lines, without exceptions. 
The old code will remain as is, but the new changes should use the style below:

if (condition) {
    doSomething();
}
"
I will try to provide appropriate formatter/save preferences soon.

Please comment or reopen bug 457592 if something is wrong.

[1] https://wiki.eclipse.org/EGit/Contributor_Guide#Braces_for_one-line_statements
[2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=457592

On Thursday 15 January 2015 17:07 Matthias Sohn wrote:
> On Tue, Jan 13, 2015 at 12:07 AM, Andrey Loskutov <loskutov@xxxxxx> wrote:
> 
> > Hi,
> >
> > I was many times beaten during the reviews of my patches to j/egit projects
> > because I always use blocks for all if/while/for/do statements,
> > independently
> > of their size, but j/egit coding style says "no braces should be used for
> > one-
> > line statements" [1].
> >
> > So this is OK for j/egit:
> >
> > if(bla)
> >   doSomething();
> >
> > but this is NOT:
> >
> > if(bla){
> >   doSomething();
> > }
> >
> > I found this rule pretty annoying for many reasons: the rule itself is not
> > only an exception from the general rule to have braces around any blocks
> > but
> > also contains another 2 exceptions that you *have to* use braces in some
> > special cases. The code containing multiple if/else block with and without
> > braces looks inconsistent, refactoring often leads to left-over braces.
> > Especially that Eclipse formatter does not remove "unnecessary" braces
> > automatically is kind of showstopper - one can't even trust Ctrl+Shift+F
> > :-).
> >
> > Is there any strong reason to keep this rule or is it just matter of taste?
> >
> > Can we please relax the guidelines and remove this rule from the coding
> > guidelines?
> >
> > [1]
> > https://wiki.eclipse.org/EGit/Contributor_Guide#Braces_for_one-line_statements
> 
> 
> +0
> 
> We should not reformat existing code globally in case we change the style
> to always use braces
> but only change style of new or modified code.
> 
> --
> Matthias

-- 
Kind regards,
google.com/+AndreyLoskutov


Back to the top