You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gary Gregory <ga...@gmail.com> on 2019/09/11 13:53:50 UTC

[CONFIGURATION] Formatting braces

Hi All:

I only hope that this will not turn into a bike shedding thread...

Commons Configuration is one of the few components we have that uses the
formatting rule (enforced by Checkstyle) where braces must be on separate
lines. In the age of lambdas, this is, IMO, lame (a technical term ;-) for
example:

    public static final ConfigurationConsumer<ConfigurationException>
DEFAULT_INCLUDE_LISTENER = e ->
    {
        throw e;
    };

    public static final ConfigurationConsumer<ConfigurationException>
NOOP_INCLUDE_LISTENER = e ->
    {
        // noop
    };

Instead of:

    public static final ConfigurationConsumer<ConfigurationException>
DEFAULT_INCLUDE_LISTENER = e -> { throw e; };

    public static final ConfigurationConsumer<ConfigurationException>
NOOP_INCLUDE_LISTENER = e -> { /* noop */ };

I propose a reformatting to use the "{ on the same line" which means that
blocks go from:

if (test)
{
   // this
}
else
{
  // that
}

to:

if (test) {
   // this
} else {
  // that
}

and so on.

Gary

Re: [CONFIGURATION] Formatting braces

Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Sep 12, 2019 at 1:11 PM Thomas Vandahl <tv...@apache.org> wrote:

> On 11.09.19 15:53, Gary Gregory wrote:
> >     public static final ConfigurationConsumer<ConfigurationException>
> > DEFAULT_INCLUDE_LISTENER = e -> { throw e; };
> >
> >     public static final ConfigurationConsumer<ConfigurationException>
> > NOOP_INCLUDE_LISTENER = e -> { /* noop */ };
>
> +1 for these.
>
> > I propose a reformatting to use the "{ on the same line" which means that
> > blocks go from:
> >
> > if (test)
> > {
> >    // this
> > }
> > else
> > {
> >   // that
> > }
> >
> > to:
> >
> > if (test) {
> >    // this
> > } else {
> >   // that
> > }
>
> -1 here. At least not for all components.
>

I was only talking about Configuration here.

Gary


>
> Bye, Thomas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Re: [CONFIGURATION] Formatting braces

Posted by Thomas Vandahl <tv...@apache.org>.
On 11.09.19 15:53, Gary Gregory wrote:
>     public static final ConfigurationConsumer<ConfigurationException>
> DEFAULT_INCLUDE_LISTENER = e -> { throw e; };
> 
>     public static final ConfigurationConsumer<ConfigurationException>
> NOOP_INCLUDE_LISTENER = e -> { /* noop */ };

+1 for these.

> I propose a reformatting to use the "{ on the same line" which means that
> blocks go from:
> 
> if (test)
> {
>    // this
> }
> else
> {
>   // that
> }
> 
> to:
> 
> if (test) {
>    // this
> } else {
>   // that
> }

-1 here. At least not for all components.

Bye, Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


RE: [CONFIGURATION] Formatting braces

Posted by Mark Roberts <ma...@cs.washington.edu>.
That's exactly what we do with all our projects here at UW/PLSE.
Mark

-----Original Message-----
From: James Ring [mailto:sjr@jdns.org] 
Sent: Friday, September 13, 2019 6:44 AM
To: Commons Developers List <de...@commons.apache.org>
Subject: Re: [CONFIGURATION] Formatting braces

What about https://github.com/google/google-java-format ? Just require that it be run on check-in, all these style questions go away (as a bonus, it looks nice too).

On Wed, Sep 11, 2019 at 6:54 AM Gary Gregory <ga...@gmail.com> wrote:
>
> Hi All:
>
> I only hope that this will not turn into a bike shedding thread...
>
> Commons Configuration is one of the few components we have that uses 
> the formatting rule (enforced by Checkstyle) where braces must be on 
> separate lines. In the age of lambdas, this is, IMO, lame (a technical 
> term ;-) for
> example:
>
>     public static final ConfigurationConsumer<ConfigurationException>
> DEFAULT_INCLUDE_LISTENER = e ->
>     {
>         throw e;
>     };
>
>     public static final ConfigurationConsumer<ConfigurationException>
> NOOP_INCLUDE_LISTENER = e ->
>     {
>         // noop
>     };
>
> Instead of:
>
>     public static final ConfigurationConsumer<ConfigurationException>
> DEFAULT_INCLUDE_LISTENER = e -> { throw e; };
>
>     public static final ConfigurationConsumer<ConfigurationException>
> NOOP_INCLUDE_LISTENER = e -> { /* noop */ };
>
> I propose a reformatting to use the "{ on the same line" which means 
> that blocks go from:
>
> if (test)
> {
>    // this
> }
> else
> {
>   // that
> }
>
> to:
>
> if (test) {
>    // this
> } else {
>   // that
> }
>
> and so on.
>
> Gary

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [CONFIGURATION] Formatting braces

Posted by James Ring <sj...@jdns.org>.
What about https://github.com/google/google-java-format ? Just require
that it be run on check-in, all these style questions go away (as a
bonus, it looks nice too).

On Wed, Sep 11, 2019 at 6:54 AM Gary Gregory <ga...@gmail.com> wrote:
>
> Hi All:
>
> I only hope that this will not turn into a bike shedding thread...
>
> Commons Configuration is one of the few components we have that uses the
> formatting rule (enforced by Checkstyle) where braces must be on separate
> lines. In the age of lambdas, this is, IMO, lame (a technical term ;-) for
> example:
>
>     public static final ConfigurationConsumer<ConfigurationException>
> DEFAULT_INCLUDE_LISTENER = e ->
>     {
>         throw e;
>     };
>
>     public static final ConfigurationConsumer<ConfigurationException>
> NOOP_INCLUDE_LISTENER = e ->
>     {
>         // noop
>     };
>
> Instead of:
>
>     public static final ConfigurationConsumer<ConfigurationException>
> DEFAULT_INCLUDE_LISTENER = e -> { throw e; };
>
>     public static final ConfigurationConsumer<ConfigurationException>
> NOOP_INCLUDE_LISTENER = e -> { /* noop */ };
>
> I propose a reformatting to use the "{ on the same line" which means that
> blocks go from:
>
> if (test)
> {
>    // this
> }
> else
> {
>   // that
> }
>
> to:
>
> if (test) {
>    // this
> } else {
>   // that
> }
>
> and so on.
>
> Gary

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [CONFIGURATION] Formatting braces

Posted by sebb <se...@gmail.com>.
On Wed, 11 Sep 2019 at 15:15, Gary Gregory <ga...@gmail.com> wrote:
>
> On Wed, Sep 11, 2019 at 10:12 AM Gilles Sadowski <gi...@gmail.com>
> wrote:
>
> > Hello.
> >
> > +1
> >
> > Le mer. 11 sept. 2019 à 15:54, Gary Gregory <ga...@gmail.com> a
> > écrit :
> > >
> > > Hi All:
> > >
> > > I only hope that this will not turn into a bike shedding thread...
> >
> > A uniform coding style (for all components); that *seems* obvious (too)...
> >
>
> Well, yes, it would be nice to share Checkstyle, SpotBugs, and PMD
> configurations but I am only taking one small manageable step here.

+1 in this case; separate lines don't make sense for lambdas

> Gary
>
>
> > Gilles
> >
> > >
> > > Commons Configuration is one of the few components we have that uses the
> > > formatting rule (enforced by Checkstyle) where braces must be on separate
> > > lines. In the age of lambdas, this is, IMO, lame (a technical term ;-)
> > for
> > > example:
> > >
> > >     public static final ConfigurationConsumer<ConfigurationException>
> > > DEFAULT_INCLUDE_LISTENER = e ->
> > >     {
> > >         throw e;
> > >     };
> > >
> > >     public static final ConfigurationConsumer<ConfigurationException>
> > > NOOP_INCLUDE_LISTENER = e ->
> > >     {
> > >         // noop
> > >     };
> > >
> > > Instead of:
> > >
> > >     public static final ConfigurationConsumer<ConfigurationException>
> > > DEFAULT_INCLUDE_LISTENER = e -> { throw e; };
> > >
> > >     public static final ConfigurationConsumer<ConfigurationException>
> > > NOOP_INCLUDE_LISTENER = e -> { /* noop */ };
> > >
> > > I propose a reformatting to use the "{ on the same line" which means that
> > > blocks go from:
> > >
> > > if (test)
> > > {
> > >    // this
> > > }
> > > else
> > > {
> > >   // that
> > > }
> > >
> > > to:
> > >
> > > if (test) {
> > >    // this
> > > } else {
> > >   // that
> > > }
> > >
> > > and so on.
> > >
> > > Gary
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [CONFIGURATION] Formatting braces

Posted by Gary Gregory <ga...@gmail.com>.
On Wed, Sep 11, 2019 at 10:12 AM Gilles Sadowski <gi...@gmail.com>
wrote:

> Hello.
>
> +1
>
> Le mer. 11 sept. 2019 à 15:54, Gary Gregory <ga...@gmail.com> a
> écrit :
> >
> > Hi All:
> >
> > I only hope that this will not turn into a bike shedding thread...
>
> A uniform coding style (for all components); that *seems* obvious (too)...
>

Well, yes, it would be nice to share Checkstyle, SpotBugs, and PMD
configurations but I am only taking one small manageable step here.

Gary


> Gilles
>
> >
> > Commons Configuration is one of the few components we have that uses the
> > formatting rule (enforced by Checkstyle) where braces must be on separate
> > lines. In the age of lambdas, this is, IMO, lame (a technical term ;-)
> for
> > example:
> >
> >     public static final ConfigurationConsumer<ConfigurationException>
> > DEFAULT_INCLUDE_LISTENER = e ->
> >     {
> >         throw e;
> >     };
> >
> >     public static final ConfigurationConsumer<ConfigurationException>
> > NOOP_INCLUDE_LISTENER = e ->
> >     {
> >         // noop
> >     };
> >
> > Instead of:
> >
> >     public static final ConfigurationConsumer<ConfigurationException>
> > DEFAULT_INCLUDE_LISTENER = e -> { throw e; };
> >
> >     public static final ConfigurationConsumer<ConfigurationException>
> > NOOP_INCLUDE_LISTENER = e -> { /* noop */ };
> >
> > I propose a reformatting to use the "{ on the same line" which means that
> > blocks go from:
> >
> > if (test)
> > {
> >    // this
> > }
> > else
> > {
> >   // that
> > }
> >
> > to:
> >
> > if (test) {
> >    // this
> > } else {
> >   // that
> > }
> >
> > and so on.
> >
> > Gary
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Re: [CONFIGURATION] Formatting braces

Posted by Gilles Sadowski <gi...@gmail.com>.
Hello.

+1

Le mer. 11 sept. 2019 à 15:54, Gary Gregory <ga...@gmail.com> a écrit :
>
> Hi All:
>
> I only hope that this will not turn into a bike shedding thread...

A uniform coding style (for all components); that *seems* obvious (too)...

Gilles

>
> Commons Configuration is one of the few components we have that uses the
> formatting rule (enforced by Checkstyle) where braces must be on separate
> lines. In the age of lambdas, this is, IMO, lame (a technical term ;-) for
> example:
>
>     public static final ConfigurationConsumer<ConfigurationException>
> DEFAULT_INCLUDE_LISTENER = e ->
>     {
>         throw e;
>     };
>
>     public static final ConfigurationConsumer<ConfigurationException>
> NOOP_INCLUDE_LISTENER = e ->
>     {
>         // noop
>     };
>
> Instead of:
>
>     public static final ConfigurationConsumer<ConfigurationException>
> DEFAULT_INCLUDE_LISTENER = e -> { throw e; };
>
>     public static final ConfigurationConsumer<ConfigurationException>
> NOOP_INCLUDE_LISTENER = e -> { /* noop */ };
>
> I propose a reformatting to use the "{ on the same line" which means that
> blocks go from:
>
> if (test)
> {
>    // this
> }
> else
> {
>   // that
> }
>
> to:
>
> if (test) {
>    // this
> } else {
>   // that
> }
>
> and so on.
>
> Gary

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org