I like braces too. For this kind of mass edit though, I’m not about to
start changing anything that isn’t already touched by the formatter,
that’s a never-ending rat-hole and rife with possibilities to screw
up.
What that means in this case is that the formatter changes
if (something)
blah
to
if (something) blah
and it shows up in the diff.
Since the last person to deal with that code intended “blah” to be
on a separate line, I’ll add braces put “blah” back on it’s own line:
if (something) {
blah
}
OTOH, since the formatter doesn’t touch
if (something) blah
I won’t either. I’m sure I’ll miss some, but since it’s functionally equivalent
I don’t care. BTW, I’ve even seen a couple of
for (whatever)
blah;
which I think is horrible. Again, though, if the formatter touches it I’ll
put in braces, otherwise I won’t even see it.
Martin Fowler in his book “refactoring” argues that there’s no
point in rewriting code _unless_ it’s relevant to a problem you’re solving.
In this case that means something that’s being reformatted anyway….
FWIW,
Erick
> On Dec 24, 2020, at 1:40 PM, Gus Heck <[email protected]> wrote:
>
> +1 to always braces
>
> On Thu, Dec 24, 2020 at 11:47 AM Michael Sokolov <[email protected]> wrote:
> The Google convention you cited says this, I think?
>
> > Braces are used with if, else, for, do and while statements, even when
> > the body is empty or contains only a single statement.
>
> On Thu, Dec 24, 2020 at 8:00 AM Dawid Weiss <[email protected]> wrote:
> >
> > > Personally I would ban the non block conditional, but I think it's moot
> > > in this context since spotless just does what it does and is not
> > > configurable, as I understand it. I suppose we could manually "fix" all
> > > the conditionals though?
> >
> > I'm pretty sure you could do it automatically... But in many places
> > there is very little sense in doing that. That google format
> > convention [1] is fairly reasonable to me - strict in certain aspects
> > and relaxed elsewhere. I wouldn't enforce it. If you find a place that
> > could use more clarity with braces, correct it (and re-run the
> > formatting) then commit it back in.
> >
> > Dawid
> >
> > https://google.github.io/styleguide/javaguide.html
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
> --
> http://www.needhamsoftware.com (work)
> http://www.the111shift.com (play)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]