Static Code Analysis Tools?

E

Eric Schwartz

I was searching through CPAN today for a module that would generate a
static call tree, but couldn't seem to find one (lots of dynamic call
tree generators, though!). I'm less concerned with code coverage at
this point; I'm looking for a module (or tool) that will help me
refactor code by easily showing me who calls, say, MyMod::Foo.

Does anyone know of such a thing?

-=Eric
 
E

Eric Schwartz

Eric> I was searching through CPAN today for a module that would generate a
Eric> static call tree, but couldn't seem to find one (lots of dynamic call
Eric> tree generators, though!). I'm less concerned with code coverage at
Eric> this point; I'm looking for a module (or tool) that will help me
Eric> refactor code by easily showing me who calls, say, MyMod::Foo.

Eric> Does anyone know of such a thing?

Does B::Xref fit?

I think it can be made to-- thanks! It looks like it's intended to be
run on a program, and recursively descend down its call-tree, yes?
Which isn't a problem, I think-- if I have a sub in a module that
doesn't appear after running that code over all my executables, then
clearly that sub can be moved anywhere (or preferably, deleted).

-=Eric
 
M

Michele Ouellet

Which isn't a problem, I think-- if I have a sub in a module that
doesn't appear after running that code over all my executables, then
clearly that sub can be moved anywhere (or preferably, deleted).

Well, it is not quite clear to me. Of course, I have not looked at B::Xref
but it seems to me that if the sub does not appear, it can mean one of two
things:

* it is dead wood:
OR
* it is invoked based on some combination of conditions which were just not
exercised during your test.

Am I missing something?

Michèle.
 
B

Brian McCauley

Eric said:
I was searching through CPAN today for a module that would generate a
static call tree, but couldn't seem to find one (lots of dynamic call
tree generators, though!). I'm less concerned with code coverage at
this point; I'm looking for a module (or tool) that will help me
refactor code by easily showing me who calls, say, MyMod::Foo.

Does anyone know of such a thing?

Beacuse Perl is not strongly typed it is impossible for static analysis
to resolve method calls.

It's also not possible for static analysis to resolve subroutine calls
through symrefs, run-time aliases or eval().

But subject to those limitations Perl does, as others have pointed out,
come with a static cross-reference tool.
 
E

Eric Schwartz

Brian McCauley said:
Beacuse Perl is not strongly typed it is impossible for static
analysis to resolve method calls.

That's okay; I'll consider myself successful if I can get everybody to
stick to our coding standards, never mind teaching them OOP. :)
It's also not possible for static analysis to resolve subroutine calls
through symrefs, run-time aliases or eval().

Also true. Thankfully, with the exception of dispatch tables, we have
officially deemed most of those Evil(tm)(c)(r).

-=Eric
 
B

Brian McCauley

Randal said:
Brian> Beacuse Perl is not strongly typed

Well, for some definitions of "strongly typed".

OK sorry for my sloppy teminiology. I, of course, meant that you cannot
in general know the type of an object at compile time.
Some would loudly disagree with you, for example.

Such loud disagreements always remind me of a passage from "Surely
You're Joking Mr Feynman".

I was able to find this passage quoted on the net in the following
"Letter to Professor Feynman". It starts in the last paragraph of the
3rd page (which is numbered page 442).

http://www.thoughtsandvisions.com/feynlet.pdf

Read and enjoy!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top