Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Mandatory indenting

by Zed_Lopez (Chaplain)
on Jun 20, 2003 at 19:14 UTC ( #267688=note: print w/ replies, xml ) Need Help??


in reply to Re: Mandatory indenting
in thread Mandatory indenting

I don't like the idea of a language enforcing mandatory indenting, but a common indenting style is a good thing for a team project. That way you can diff two versions of a file and see real differences between them without a zillion irrelevant differences because two programmers have different indenting styles. That's why I configured CVS to reject any code that hasn't been perltidied. It's a little obnoxious, but the effort more than pays for itself. (And cool hack, juerd.)


Comment on Re: Re: Mandatory indenting
Re: Re: Re: Mandatory indenting
by Maclir (Curate) on Jun 20, 2003 at 19:30 UTC
    ++Zed for setting sensible project and team standards.
Re: Re: Re: Mandatory indenting
by demerphq (Chancellor) on Jun 22, 2003 at 15:54 UTC

    How does your CVS know the code hasnt been tidied and thus to reject? I personally tend to tidy code before I put it under source control, but have no automatic procedure for doing so. Id like to hear more.


    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

      tidy it again and see if it changes :)

        Doh. :-)

        rotfl ++Anonny!


        ---
        demerphq

        <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

        An adaptation of this script might work in that regard. It was a shell script I hacked together to reformat occasionally as I worked on things. Given one or more files on the command line, it looks to see if there is a .tdy version of the file present (creating an empty one if not), checks if the current version and the .tdy version differ, and if so, performs a tidy (setting the lines 123 characters-personal preference), not replacing the original if a .ERR file was produced. The .tdy file was also left in place for future comparison.

        #!/bin/bash PERLTIDY='/usr/local/bin/perltidy -l 123 ' TOUCH=/bin/touch DIFF=/usr/bin/diff WC=/usr/bin/wc CP=/bin/cp if [ $# -gt 0 ] then echo Command line: $0 $@ for file in $@ do if [ ! -e $file.tdy ] then $TOUCH $file.tdy fi if [ `$DIFF -q $file $file.tdy | $WC -l` -gt 0 ] then $PERLTIDY $file if [ -e $file.ERR ] then echo Error detected-not replacing else $CP -v $file.tdy $file fi else echo Skipping $file - perltidy on file not necessary fi done else echo Usage: $0 filename fi

        Update (20 Jan 2004): Added absolute paths to utilities used, to prevent issues with pathing.

      I would suspect it would involve using an entry in the commitinfo administrative file, although I am not sure of the exact format of the entry, or if it would be necessary to involve a script calling PerlTidy, or if it could be done from PerlTidy itself.

      I find the idea intriguing, though, and would be interested in hearing more about it as well.

        I've often thought of setting up a tidy mirror. Basically mirror my entire site/lib and lib/ (and what I call /devlib) in tidied form. Also if statically generated it would be a nice resource for online somewhere. (The HTMLized ouput that is.)


        ---
        demerphq

        <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://267688]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-10-23 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls