Skip to main content

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

Hi all,

So far we've got 4 +1 responses and no one -1 to the original mail.

I've created bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=457592 to finalize possible decision to remove the "no braces for one-line statements" rule.

The bug is for EGit product but I expect that this is true for JGit too. Please comment on the bug if you have concerns. 
I would wait for a week from now and if nobody would raise hands I will change the wiki accordingly.

Now I have new questions (*only* under assumption that braces will be finally allowed for single line statements):

1) Should we always *enforce* braces usage in guidelines?
2) Should we add "save actions" to the editor which will always *enforce* braces?
3) Should we update existing code?

I'm personally for 1) and 2) (because this will affect only changed code), but have fear that 3) is too much and not worth the effort.

Opinions?

Kind regards,
Andrey Loskutov

http://google.com/+AndreyLoskutov

> Gesendet: Donnerstag, 15. Januar 2015 um 14:01 Uhr
> Von: "Robin Stocker" <robin@xxxxxxxxx>
> An: "laurent goubet" <laurent.goubet@xxxxxxx>
> Cc: egit-dev@xxxxxxxxxxx
> Betreff: Re: [egit-dev] Allow to always use blocks for if/while/for/do	statements?
>
> +1. It's a waste of time and energy on reviews.
> 
> And yes, it's inconsistent which prevents use of the formatter and
> save actions, see this change and referenced ones:
> 
> https://git.eclipse.org/r/#/c/5753/
> 
> Cheers,
>   Robin
> 
> > I'd like to voice a big +1 on this... This rule is painful and not
> > even
> > consistent (do not use a block on single-line if, except if the
> > content
> > is too big... in which case use a block even if it's a single line).
> > I'd
> > argue that something the formatter cannot do alone is not a good
> > practice...
> > 
> > Laurent
> > 
> > On 13/01/2015 00:07, Andrey Loskutov 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
> _______________________________________________
> egit-dev mailing list
> egit-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/egit-dev
> 


Back to the top