You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Daniel Quinlan <qu...@pathname.com> on 2004/02/10 22:42:02 UTC

perl indentation standard

Okay, I think this is closer to what we're using, but after looking at
the output, I'm not so sure about using perltidy on our existing code.

Note: If your version of perltidy is old (Debian's was from 2001), you
can get a new version in various formats at http://perltidy.sourceforge.net/

------- start of cut text --------------
# perltidyrc
 -i=2    # use n columns per indentation level (default n=4)
 -nt     # no tabs: use n spaces per indentation level (default)
 -bt=1   # sets brace tightness,  n= (0 = loose, 1=default, 2 = tight)
 -pt=2   # paren tightness (n=0, 1 or 2)
 -sbt=2  # square bracket tightness (n=0, 1, or 2)
 -nce    # no "cuddled else" (default)
 -nbl    # opening brace on the same line as the introducing keyword (default)
 -lp     # line up parentheses
 -noll   # no outdenting (do not remove indentation on long lines)
 -et=8   # entab the leading whitespace of a line (8 spaces per tab)
------- end ----------------------------

I think we also want:

 -msc=8  # minimum space to comment

and perhaps some -vt options.  Those are hella-confusing.

The above isn't quite right though.  You end up with some wacky stuff
like this:

------- start of cut text --------------
$re_loose =
  'applet|basefont|center|dir|font|frame|frameset|iframe|isindex|menu|noframes|s|strike|u';
------- end ----------------------------

That is, a silly line break that buys you nothing.

------- start of cut text --------------
		   start_document => [sub { $self->html_init(@_) }],
		   start => [sub { $self->html_tag(@_) }, "tagname,attr,'+1'"],
		   end  => [sub { $self->html_tag(@_) },  "tagname,attr,'-1'"],
		   text => [sub { $self->html_text(@_) }, "dtext"],
		   comment     => [sub { $self->html_comment(@_) },     "text"],
		   declaration => [sub { $self->html_declaration(@_) }, "text"],
------- end ----------------------------

I don't know what isn't set right here, but it looks like:

 1. extra spaces are being put around => which is annoying
 2. it's one character too wide (79 should be used as the maxwidth, not 80)
 3. the extra spaces after , are also annoying

I could also do without the following silly pretty-printing:

------- start of cut text --------------
  $self->{html}{ratio}               = 0;
  $self->{html}{image_area}          = 0;
  $self->{html}{shouting}            = 0;
  $self->{html}{max_shouting}        = 0;
  $self->{html}{total_comment_ratio} = 0;
  $self->{html}{title_index}         = -1;
------- end ----------------------------

Bleh.  Who wants to maintain the above spacing.  This means every time
one line is added, the entire thing has to be reindented and svn
annotate can't tell who added what.

------- start of cut text --------------
    if (
       !(exists $self->{html}{"inside_head"} && $self->{html}{"inside_head"} > 0
       )
      )
------- end ----------------------------

The above is also silly.  Why bother with all those newlines???

------- start of cut text --------------
  if (   $self->{html_last_tag} eq "div"
      && $text =~ /Converted from text\/plain format/)
  {
------- end ----------------------------

And that needs to go too.  I don't want it trying to line up elements
($self and $text) like that.

Does perltidy have enough flexibility to fix all this crap?

Ugh, another annoyance in the works:

------- start of cut text --------------
      dbg(  "auto-learn? no: too few head hits ("
          . $self->{head_only_hits} . " < "
          . $required_head_hits
          . ")");
------- end ----------------------------

Why use so many lines for what can be put on one or two and be *more*
readable.

Daniel

-- 
Daniel Quinlan                     anti-spam (SpamAssassin), Linux,
http://www.pathname.com/~quinlan/    and open source consulting