pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus KARG <markus@headcrashing.eu>
To: 'List' <pgsql-jdbc@postgresql.org>
Subject: Re: PgJDBC: code reformat
Date: Sun, 27 Dec 2015 00:04:25 +0100
Message-ID: <062c01d14031$c4f01aa0$4ed04fe0$@eu> (raw)
In-Reply-To: <CAB=Je-F1PtJ1Dbsswr=oaj2z8KYpZANHW_kLc2y5DuzjpAJqeQ@mail.gmail.com>
References: <CAB=Je-F1PtJ1Dbsswr=oaj2z8KYpZANHW_kLc2y5DuzjpAJqeQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

-0 [X] I would rather go with Sun style instead of Google style; it is contained in Eclipse as a selectable option, so I don't have to configure my IDE at all but can rely on auto-format on saving a file. :-)

-Markus

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Vladimir Sitnikov
Sent: Samstag, 26. Dezember 2015 22:41
To: List
Subject: [JDBC] PgJDBC: code reformat

Hi,

I would like to raise a discussion on coding guidelines.
As discussed, single style is good.

As there are no suggestions, I went ahead and tried "Google style, 100 characters per line".
Here are some of the results: [1], [2], [3] I've spent ~3 hours to achieve that, notable part of which was figuring out how to configure checkstyle.

What works:
0) IDEA reformat gives checkstyle-compatible code
1) IDEA checkstyle plugin can show violations
2) mvn checkstyle:check
3) Travis

Please vote:
+1 [ ] The style is wonderful
+0 [ ] It is good enough
-0 [ ] Generally it is ok, but ...
-1 [ ] I do not like it since ...

Google style basically means:
1) K&R Egyptian brackets
2) Line break is inserted _before_ binary operators.
For instance:
   "line 1"
   + "line 2"
3) Every variable should be declared on its own line. In other words, "int a,b;" is forbidden
4) Certain variable & method naming conventions (<-- I have not yet looked into this)

My idea is to see how far IDEA can reformat the code to please checkstyle validator.
I've taken checkstyle configuration from their official sample (see
[5]) and disabled certain checks (the ones that cannot be applied automatically like variable naming conventions).

There are still some checkstyle warnings (I think they should be converted to errors): [4]

[1] https://github.com/pgjdbc/pgjdbc/blob/format_code/pgjdbc/src/main/java/org/postgresql/jdbc/PgStateme...
[2] https://github.com/pgjdbc/pgjdbc/blob/format_code/pgjdbc/src/main/java/org/postgresql/jdbc/AbstractB...
[3] https://github.com/pgjdbc/pgjdbc/blob/format_code/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabas...
[4] https://travis-ci.org/pgjdbc/pgjdbc/jobs/98907638
[5] https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml

--
Regards,
Vladimir Sitnikov


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (33+ messages)  latest in thread

Message-ID: <062c01d14031$c4f01aa0$4ed04fe0$@eu>
Permalink:  ../062c01d14031$c4f01aa0$4ed04fe0$@eu/
Also on:    postgresql.org/message-id/062c01d14031$c4f01aa0$4ed04fe0$@eu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: markus@headcrashing.eu
  Subject: Re: PgJDBC: code reformat
  In-Reply-To: <062c01d14031$c4f01aa0$4ed04fe0$@eu>
  References: <CAB=Je-F1PtJ1Dbsswr=oaj2z8KYpZANHW_kLc2y5DuzjpAJqeQ@mail.gmail.com> <062c01d14031$c4f01aa0$4ed04fe0$@eu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox