mr.dunstan has asked for the wisdom of the Perl Monks concerning the following question:

Anyone out there build your own code analysis tools to do things like automated testing, query validation and so forth?

I've been trying to figure out ways of reading and refactoring some really old code while also determining how much change is actually necessary (ie. if I change this one thing, how far does the ripple of change carry me?)

I know there are fancy expensive tools out there for some other languages which will remain nameless, but what about for perl?

I suppose the short answer is, "Write better code, stupid!" But what if I'm stuck with other people's code, and a LOT of it!?

mr.dunstan

Replies are listed 'Best First'.
(Ovid) Re: Code Analysis Tools?
by Ovid (Cardinal) on Jun 23, 2001 at 03:59 UTC

    The only thing that I know of that seems to describe what you are looking for is Silktest, but it's expensive and has a proprietary programming language (and, according to rumor, the company may go bankrupt). I'd love to see something like that allows one to easily construct a 'use case' and test against it.

    Other than that, the only thing I can think of is to examine your code base, figure out your data sources and see if you can write a code generator for them. It can take quite a bit of work to create a good one, but the effort is worthwhile. I wrote a script to automatically generate form parsing code to deal with a large Web site that had a lot of very poorly done form handling. By creating standard error routines and running the generator against against my Web-based forms, I've been able to do a lot of conversion work quickly and easily. I realize that this is not exactly what you are looking for, as this primarily deals with capturing data and not processing, but it might be a start.

    Cheers,
    Ovid

    Vote for paco!

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: Code Analysis Tools?
by p3rl (Novice) on Jun 23, 2001 at 18:32 UTC
    I see what you mean. There is a numerous number of tools out there for other languages but maybe not even a hanfyll for Perl. Maybe this is a sign, write one. Even though this may be a vast task you can make things easier if you get a few people together to make things a bit easier.
Re: Code Analysis Tools?
by mr.dunstan (Monk) on Jun 23, 2001 at 21:52 UTC
    Whoo, I think I asked a 2-prong question, which was not necessarily exactly the question I was trying to ask, but in hindsight, is still, I think, a pretty good one ...

    We -are- actually using Silk to do our automated testing! I didn't hear the rumor though, thanks for the info! I guess it works fairly well as long as our test engineers can keep up with UI changes.

    The thing I'm really thinking about should actually be called a "code validator", I think.

    It would make sure all SQL queries in the code were at least somewhat sane, hopefully figure out an automatic way to test individual subs/methods, figure out if/when/where we've got really nasty duplication, and mainly to figure out what breaks if I change this little piece of obscure code over here .... hmm ... *sound of code breaking noisily*

    Maybe I should just pray to the Perl Buddha instead!

    PS: ovid - that's a nice piece of code there. Code that makes other code is always super super cool in my book! The next time I get to do a ground-up project I am most certainly going to do some kind of component generation if I can! It makes sense and it's so sheik!!


    regards,
    -mr.dunstan