views:

41

answers:

1

I've got a Codebase of around 5,3k LOC with around 30 different classe. The code is already very well formatted and I want to improve it further by prefixing methods that are only called in the module that were defined in with a "_", in order to indicate that. Yes it would have been a good idea to do that from the beginning on but now it's too late :D

Basically I'm searching for a tool that will tell me if a method is not called outside of the module it was defined in, I'm not looking for stuff that will automatically convert the whole thing to use underscores, just a "simple" thing that tells me where I have to look for prefixing stuff.

I'd took a look at the AST module, but there's no easy way to get a list of method definitions and calls, also parsing the plain text yields just too many false positives. I don't insist in spending day(s) on reinventing the wheel when there might be an already existing solution to my problem.

A: 

For me, this sounds like special case of coverage.

Thus I'd take a look at coverage.py or figleaf and modify it to ignore inter-module calls.

Almad
Digging in other peoples code is even harder than writing something from scratch by my self I think, but anyways I didn't know of coverage/figleaf before so thanks for that, since it already found a bit of dead code :)
Ivo Wetzel