fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([staff profile] fu) wrote2011-03-01 11:37 pm

perltidy is so tempting

You could tie perltidy to the mercurial commit hook, and use that as an automatic checker for style before commit.

We have so much old code in various styles, this would be much easier than tweaking things by hand to make everything conform, and once you've gotten past that first big burst of formatting, you could run it again and see any style issues in any new patches.

And yet, and yet...
exor674: Computer Science is my girlfriend (Default)

[personal profile] exor674 2011-03-01 06:16 pm (UTC)(link)
I really don't trust automatic code formatters, especially on large codebases.

One bug in the formatter, and it noms some $foo->prevent_xss_funtimes; check. *g*
pauamma: Cartooney crab holding drink (Default)

[personal profile] pauamma 2011-03-01 06:46 pm (UTC)(link)
You could wrap it in something that pipes both original and tidied version through tr -d ' \n\t\v\f\r' and cmp the results.
pauamma: Cartooney crab holding drink (Default)

[personal profile] pauamma 2011-03-02 04:33 pm (UTC)(link)
That would still give spurious diffs when moving stuff across linebreaks, eg when rewriting
 

if ( $foo )
{
  bar();
  quux();
}


to
 

if ( $foo ) {
    bar();
    quux();
}
Edited (Bad HTML is bad.) 2011-03-02 16:35 (UTC)
pauamma: Cartooney crab holding drink (Default)

[personal profile] pauamma 2011-03-01 06:30 pm (UTC)(link)
FRTA "perfidy is so tempting".
pauamma: Cartooney crab holding drink (Default)

[personal profile] pauamma 2011-03-02 04:37 pm (UTC)(link)
*bow* Glad I could help.