Find any methods that are never called?
-
Is there a way to find any methods that I have defined that never actually get called in my code? Not that I have any like that

I've found a few little methods that I started writing while testing something, then later found a completely different solution, but then never realized I needed to get rid of that old method. So is there such a code cleaning tool? Well, I don't want it to touch my code, I'll do that, I just want it to point me to methods that are not being called ever.
-
I just use
Notepad++and 'find' each 'def' in turn; I use 'find' for the method's name 'xxxx' and do acount, if it ==1 I know I've never used it in the script; to be doubly sure I then add=begin...=endaround the method and retest the script [NB: restart to clear unused methods]: if it works with no errors then I know it's safe to remove that unused method. It it looks like a useful method snippet I'll cut/paste it into a methods-scraps file for possible use on another project, otherwise I'll just delete it! -
@tig said:
add =begin...=end around the method and retest the script:
Make sure to restart SU before retesting. Because a
loadwill not remove the old method. Easy trap to fall into, as you won't notice something failed until you start the next time.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement