in reply to Generating report on variables and alike...

Perhaps Perl::Critic could be cajoled into doing what you want with a suitable policy?

The cake is a lie.
The cake is a lie.
The cake is a lie.

  • Comment on Re: Generating report on variables and alike...

Replies are listed 'Best First'.
Re^2: Generating report on variables and alike...
by Your Mother (Archbishop) on Apr 21, 2008 at 02:35 UTC

    This might be nice. If it's not already there somewhere, it would be great to have useless variable names like %data or rampant single letter names flagged as sub-optimal.

      Except as loop indices or as part of mathematical functions such as if ($x^2 + $y^2 == $z^2) { ... }. And, useless variables are only useless outside of context. %data might be perfectly acceptable in a properly-named function.

      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

        I think the same kind of context heuristics used for single letter names could be extended to names like %tmp, %arg, and %data (or reaonsable single letters for cases like $c/$f/$k in a temperature sub). Check their scope. They are pretty reasonable in a small loop but I'd argue that in a main:: space or a block/sub longer than...? 10? lines, they could be named better and a critic rule might suggest that. Normally when I find myself using that kind of name it's out of haste and I wouldn't mind an automated kick in the pants to make me stop for 90 seconds to think about how it will really read to the next hacker (or to me in 6 months).

Re^2: Generating report on variables and alike...
by cosmicperl (Chaplain) on Apr 22, 2008 at 19:49 UTC
    This looks good. But I'm wieghing up the time it'll take to understand Perl::Critic to putting a qnd script together.