You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Greg Brown <gk...@mac.com> on 2010/09/16 21:05:02 UTC
Code formatting
Hi all,
Just a code style request - please don't apply the code formatter to existing code unless it is really necessary. Although the formatter works pretty well, I often still manually tweak the formatting for the sake of readability. Applying the formatter generally blows away all of the manual edits. :-(
Also, I noticed that there is at least one issue with the formatter - it currently places a space between the cast operator and the operand, which we don't want:
(Foo) bar (BAD)
vs.
(Foo)bar (GOOD)
I'll post an updated version to the wiki.
Thanks,
Greg
Re: Code formatting
Posted by Greg Brown <gk...@mac.com>.
> I noticed that existing comments seem to be hacked around quite a lot by the
> Eclipse formatting profile, but assumed that was because the code pre-dated
> the profile, or was not written in Eclipse.
Actually, it seems that the comments are formatted based on a line width specified in the formatter (I had assumed that they used the workspace settings). This makes sense, though, since workspace settings would vary from developer to developer but the profile should be fixed. I have extended the comment wrap width to 100 in the formatter.
> Another option would be to have a pre-commit Ant task which would perform a
> trim-whitespace, format any changed files and any other relevant tasks.
> I don't know if it is possible to do that and limit it to just the blocks of
> code identified by a diff or something similar.
I think the best bet is probably to fix the formatter. I haven't found a way to tell it to wrap boolean expressions the way I like, but no one else seems to use my convention anyways, so maybe it is for the best. :-)
Re: Code formatting
Posted by Chris Bartlett <cb...@gmail.com>.
I noticed that existing comments seem to be hacked around quite a lot by the
Eclipse formatting profile, but assumed that was because the code pre-dated
the profile, or was not written in Eclipse.
Another option would be to have a pre-commit Ant task which would perform a
trim-whitespace, format any changed files and any other relevant tasks.
I don't know if it is possible to do that and limit it to just the blocks of
code identified by a diff or something similar.
Chris
On 17 September 2010 02:12, Greg Brown <gk...@mac.com> wrote:
> OTOH, a better approach might be to simply review the formatter thoroughly
> so we don't have to worry about this at all. I'll try to find some time to
> do that.
>
> On Sep 16, 2010, at 3:05 PM, Greg Brown wrote:
>
> > Hi all,
> >
> > Just a code style request - please don't apply the code formatter to
> existing code unless it is really necessary. Although the formatter works
> pretty well, I often still manually tweak the formatting for the sake of
> readability. Applying the formatter generally blows away all of the manual
> edits. :-(
> >
> > Also, I noticed that there is at least one issue with the formatter - it
> currently places a space between the cast operator and the operand, which we
> don't want:
> >
> > (Foo) bar (BAD)
> >
> > vs.
> >
> > (Foo)bar (GOOD)
> >
> > I'll post an updated version to the wiki.
> >
> > Thanks,
> > Greg
> >
>
>
Re: Code formatting
Posted by Greg Brown <gk...@mac.com>.
OTOH, a better approach might be to simply review the formatter thoroughly so we don't have to worry about this at all. I'll try to find some time to do that.
On Sep 16, 2010, at 3:05 PM, Greg Brown wrote:
> Hi all,
>
> Just a code style request - please don't apply the code formatter to existing code unless it is really necessary. Although the formatter works pretty well, I often still manually tweak the formatting for the sake of readability. Applying the formatter generally blows away all of the manual edits. :-(
>
> Also, I noticed that there is at least one issue with the formatter - it currently places a space between the cast operator and the operand, which we don't want:
>
> (Foo) bar (BAD)
>
> vs.
>
> (Foo)bar (GOOD)
>
> I'll post an updated version to the wiki.
>
> Thanks,
> Greg
>