Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am noticing there is a lot of redundant code in the Apex project I am working on. Is there any special way / tool or whatever to figure out what code never gets called in your code base?


share|improve this question
Check out this question:…. Perhaps some of the static code analysis tools can do what you want. – Peter Knolle Dec 18 '12 at 12:54
up vote 1 down vote accepted

At present there are no refactoring tools as such, though depending on how confident you are about the functional coverage of your Apex tests. You can utilise the code coverage as measure for this, you can also view in a colour coded way, code covered and that not.

Do make sure if your building a managed package, that before you release you scan at least for classes that are marked as 'global' as these can only be cleaned out and not removed once released.

share|improve this answer

Yeah, it calls apex test class. After running a test class you can check the code coverage and see what code is really in use.

enter image description here

share|improve this answer
This just shows which code has test code right. You may have code + test code, but never really use that code for anything functional. – Samuel De Rycke Dec 18 '12 at 12:48
But then you know that you have a test code that is never used. My example is for subconsciously unused code. – Sergey Utko Dec 18 '12 at 12:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.