Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Monday February 02, 2009
09:33 AM

Class::Sniff Reporting and Exported "Methods"

[ #38394 ]

The BBC's loss is your gain! Today, due to heavy snow in London and severe delays on the Central Line, I was concerned about being able to get home after work. They let me leave early so I've been hacking on Class::Sniff. The latest version (0.04), on its way to the CPAN, now includes reporting and detection of exported "methods". Here's a sample report:

Report for class: Grandchild

Overridden Methods
.--------+------------------------------------------------------------- -------.
| Method | Class                                                              |
+--------+------------------------------------------------------------------- -+
| bar    | Grandchild                                                         |
|        | Abstract                                                           |
|        | Child2                                                             |
| foo    | Grandchild                                                         |
|        | Child1                                                             |
|        | Abstract                                                           |
|        | Child2                                                             |
'--------+------------------------------------------------------------------ --'
Unreachable Methods
.--------+------------------------------------------------------------- -------.
| Method | Class                                                              |
+--------+------------------------------------------------------------------- -+
| bar    | Child2                                                             |
| foo    | Child2                                                             |
'--------+------------------------------------------------------------------ --'
Multiple Inheritance
.------------+----------------------------------------------------- -----------.
| Class      | Parents                                                        |
+------------+--------------------------------------------------------------- -+
| Grandchild | Child1                                                         |
|            | Child2                                                         |
'------------+-------------------------------------------------------------- --'
Exported Subroutines
.--------+---------+----------------------------------------------- -----------.
| Class  | Method  | Exported From Package                                    |
+--------+---------+--------------------------------------------------------- -+
| Child1 | croak   | Carp                                                     |
|        | inspect | Sub::Information                                         |
'--------+---------+-------------------------------------------------------- --'

Remember that class I mentioned which has 255 "methods" across 27 packages? I ran this code on it today (prior to "exported subroutine" detection) and excluded anything in the DBIx::Class namespace. It found 20 (twenty!) unreachable methods. Many of them were clearly things like 'longmess' which was exported from Carp, but still, it's a sign of a problem with the class.

I now have an idea for detecting "duplicate" methods. These happen when you cut-n-paste code. I'll go see if it works.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.