Perl Tidy
http://perltidy.sourceforge.net/
is a mechanism to ensure code is consistently formatted.
--
MartinCleaver - 02 Oct 2004
- The CodingStandards don't provide any tools to help - is the core team using anything?
- Do people like perltidy?
Can we agree on some Perltidy format parameters?
Candidates
Cut from
LiterateProgramming:
perltidy is very nice, I did the following to grab and format the latest TWiki code:
$ cvs export -r HEAD twiki grep
$ find . -type f -print | egrep -v '\.(tmpl|txt|html)|/.cvs' | xargs perltidy -ce -html
A sample of the output is attached to
PerltestOutput
--
RichardDonkin - 02 Apr 2002
I particulary liked to use following
perltidy parameters:
-
-okw -okwl="next last redo goto return exit" -- to outdent mentioned keywords: make them "stick out" to the left to show they can change program flow
-
-csc -cscw -cscp="###" -- "closing side comments" to display what statement is closed by }
Steven L. Hancock, author of
perltidy, added those for me.
My
perltidy parameters are:
-
-w -l=120 -nbl -ola -okw -okwl="next last redo goto return exit" -hsc -csc -cscw -cscp="###" -ce -sbl -wbb="+ - / *"
--
PeterMasiar - 03 Apr 2002
http://perlmonks.thepen.com/Style%20geekcode.html
--
MartinCleaver - 03 Oct 2004
http://perlmonks.thepen.com/158886.html
--
MartinCleaver - 03 Oct 2004
I'd like to make this part of our automate system - either from a nightly build perspective, or better, as part of a check on commit.
--
SvenDowideit - 31 Jan 2008
Do you want to change code formatting in the plug-in I maintain? If that's the case I would say: "please don't"

About the check on commit: I would get nervous if my commit fails because I'm missing a tab before a curly bracket.
--
StephaneLenclud - 01 Feb 2008
must admit, I wasn'tthinking about doing it to the non-core code - though I'm surprised at your fear.
--
SvenDowideit - 01 Feb 2008
Please don't do this.
It means that when people provide patches they will often fail because of whitespace differences. And merging across branches becomes a pain also.
--
KennethLavrsen - 01 Feb 2008
TWikibug:Item5301
: Item for the suggested automatic tidy at checkin.
--
SteffenPoulsen - 05 Feb 2008
merging across branches will be a pain irrespective of whether we use a consistent tool to re-format the code, or as Michael (and the rest of us do) reformatting a module by hand.
The difference is, with a tool, the reformatting will
always be consistent, whereas each one of us does different things when we reformat.
I prefer consistency.
--
SvenDowideit - 05 Feb 2008