Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to find unreferenced code in Flex Builder?

We've got several Flex projects, one of which has just been refactored. I'm wondering if there's an easy way to tell which classes and functions (if any) aren't being used any more?

I've discovered that we've definitely got some unused code, because running ASDoc on the entire project reports some compilation errors which don't get reported by Flex Builder (implying that those classes aren't being used any more). I'm hoping to find a more robust and complete method, and preferably one which can work at function level too.

like image 925
Andrew Aylett Avatar asked Mar 22 '10 11:03

Andrew Aylett


2 Answers

My ugly hack:

Using the swfdump tool from SWFtools, dump the disassembly from (all of) your swf(s):

swfdump -a my.swf > dump

Get a list of all your classes:

find . -name "*.as" -exec basename {} .as \; > classes
find . -name "*.mxml" -exec basename {} .mxml \; >> classes

Apply one list to the other:

for class in $(<classes) ; do grep -q \\\<$class\\\> dump || echo $class ; done

I am doing this on Windows, using Cygwin.

like image 143
Andrew Aylett Avatar answered Nov 05 '22 16:11

Andrew Aylett


Check out the Flex PMD tool. It was recently released in beta, but we've been using it at work for a few weeks, and it seems to work pretty nicely.

like image 43
Ross Henderson Avatar answered Nov 05 '22 16:11

Ross Henderson