David Blevins kirjoitti:
On Oct 16, 2008, at 3:48 PM, Alex Grönholm wrote:
What I'm saying is that we need a written set of guidelines so that
freshly contributed code wouldn't have to be constantly reformatted.
A good sized set of example code files would go a long way towards
this goal. If you agree with me on this, we could set up a Wiki page
for contributors where all the necessary instructions and guidelines
would go.
Now that you mention it recall that Maven had a pretty cool approach
to this with a basic doc and then actual IDE config files for Eclipse
and Intellij that people could just install.
http://maven.apache.org/developers/conventions/code.html
We could do something like that.
-David
I have created my suggestions for Eclipse code formatting/cleanup
definitions and code templates.
They can be found at:
http://paradoxx.dyndns.org/~demigod/openejb_eclipse_formatter.xml
http://paradoxx.dyndns.org/~demigod/openejb_eclipse_cleanup.xml
http://paradoxx.dyndns.org/~demigod/openejb_eclipse_codetemplates.xml
I would prefer to have these eventually hosted elsewhere.
Here are the main points of the formatting definitions.
Formatter:
- max line width is 100 characters
- indentation is 4 spaces
- javadocs are formatted
Cleanup:
- always use braces with control statements (I actually disagree with
this, and it's not even consistently used in existing code)
- removes unused imports and local variables
- removes "this" qualifier for non-static method/field accesses (where
possible)
- adds missing @Override/@Deprecated annotations
- removes unnecessary casts
- removes trailing whitespace
- corrects indentation
Code templates:
- for newly create .java files, inserts the ASL comment to the top