PerlTidy Kool-Aid is Poison

jk2addict on 2008-04-07T02:13:39

The mantra sounds good to me: use tidy to format code the same, so changesets across users truely measure code changes, not code formatting changes.

But try as I might, I just can't live with perltidy. No matter how many times I futz with options, it does what I want in some places, and completely makes no sense in other places.

For example:

BEGIN {
    use base qw/Class::Accessor::Grouped/;
    use Class::Inspector ();
    use Scalar::Util ();
    use Mango::Exception ();

__PACKAGE__->mk_group_accessors('component_class', qw/result_class/); };


becomes

BEGIN {
    use base qw/Class::Accessor::Grouped/;
    use Class::Inspector ();
    use Scalar::Util     ();
    use Mango::Exception ();

__PACKAGE__->mk_group_accessors('component_class', qw/result_class/); }


Nice work on the parans...but no reason to break that next line at all. -nanl fixes this problem, but leaves other lines of source way pas 80 columns. Sure, in this case, I can move qw/result_class/ to 'result_class' to avoid the formatting issue, but in other similiar code with more than on item in the qw//, it does the same thing.

This is just one example of many issue I have. Things like stacking and not stacking closings. Somtimes it works. Sometimes, I get this:

sub delete {
    my $self = shift;

return $self->meta->provider->delete_attributes( $self->meta->parent, {id => $self->id} ); };


turned into this:

sub delete {
    my $self = shift;

return $self->meta->provider->delete_attributes($self->meta->parent, {id => $self->id}); }


Not an improvement in my book. My current setting work about 60% of the time. The rest of the time, the output seems worse to me.

-l=72
-i=4
-ci=4
-bar
-ce
-nsbl
-sot
-sct
-pt=2
-sbt=2
-bt=2
-bbt=2
-nsfs
-asc
-dsm
-nbbb


Thanx for ... Reinforcing my prejudices ...

Ron Savage on 2008-04-08T01:50:07

Junk text to make submit work :-).

It's about consistency

perrin on 2008-04-08T16:53:32

I remember fighting code formatting standards too, in the dark years before perltidy. Now, I'm happy to trade my perfect formatting for perltidy's mostly right formatting, simply because it's so much better than how every other person formats their code. Since I'm the only programmer in the world who can format things correctly, I figure that perltidy will at least make other people's code legible for me.

I sympathize with you on the list indentation, but I think your desire to have a line here and there that disobeys the 80 column wrap is kind of pathological. Maybe the list indentation can be changed though. I know you can tell it to leave the way you split the list into lines alone. Of course then you have to get EVERYONE you share code with to use your settings, which is why I just use all the defaults.

Re:It's about consistency

jk2addict on 2008-04-09T00:06:09

True. In the end, it's goin to be a matter of learning to worry about what the code does, and leave how it 'reads' to tindy and moving on with life.