Static Code Analysis Tools?

Discussion in 'Perl Misc' started by Eric Schwartz, Dec 16, 2004.

  1. 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
    --
    Come to think of it, there are already a million monkeys on a million
    typewriters, and Usenet is NOTHING like Shakespeare.
    -- Blair Houghton.
     
    Eric Schwartz, Dec 16, 2004
    #1
    1. Advertising

  2. (Randal L. Schwartz) writes:
    >>>>>> "Eric" == Eric Schwartz <> writes:

    > 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
    --
    Come to think of it, there are already a million monkeys on a million
    typewriters, and Usenet is NOTHING like Shakespeare.
    -- Blair Houghton.
     
    Eric Schwartz, Dec 16, 2004
    #2
    1. Advertising

  3. > 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.
     
    Michele Ouellet, Dec 17, 2004
    #3
  4. Eric Schwartz wrote:

    > 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.
     
    Brian McCauley, Dec 17, 2004
    #4
  5. Brian McCauley <> writes:
    > 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
    --
    Come to think of it, there are already a million monkeys on a million
    typewriters, and Usenet is NOTHING like Shakespeare.
    -- Blair Houghton.
     
    Eric Schwartz, Dec 17, 2004
    #5
  6. Randal L. Schwartz wrote:

    >>>>>>"Brian" == Brian McCauley <> writes:

    >
    >
    > 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!
     
    Brian McCauley, Dec 18, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Derek
    Replies:
    2
    Views:
    438
    Ron Natalie
    Mar 4, 2005
  2. Don

    Static Code Analysis Tools

    Don, Jul 25, 2003, in forum: C Programming
    Replies:
    1
    Views:
    401
    Eric Sosman
    Jul 25, 2003
  3. Richard
    Replies:
    10
    Views:
    707
    Francesco
    Sep 6, 2009
  4. ssubbarayan
    Replies:
    5
    Views:
    2,425
    Dave Hansen
    Nov 3, 2009
  5. Brian Jiang
    Replies:
    11
    Views:
    2,213
    Jorgen Grahn
    Dec 30, 2010
Loading...

Share This Page