function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
John Manager Training DepJohn Manager Training Dep 

How to analyze existing Apex code?

Hi,

I have been onboarded to a team which is implemented on salesforce.com.

I have been asked to analyze the apex codes, triggers, and visual force code and determine which one's are being used and which one's are not?

Any suggestions?
Alain CabonAlain Cabon
@John  

The SymbolTable contains all the interesting things for this need but it is not trivial to get the results easily. I got it with java programs and the guidelines given by Daniel Ballinger on the forums at first.

ExternalReferences Type : array of ExternalReference
Description: Contains the name, namespace, external class, method, and variable references for the Apex class or trigger. These references can be used for symbol highlighting or code navigation.
https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_symboltable.htm

By scanning all the symbol tables, you can find the unused code.
https://salesforce.stackexchange.com/questions/33903/how-can-i-find-unused-methods-and-variables

Apex Code Analysis Tool using Tooling API and Canvas
https://github.com/afawcett/apex-codeanalysis

The first easy step for the documentation is to use: ApexDoc  ( a simple text parsing of the code with regular expressions )
https://github.com/SalesforceFoundation/ApexDoc

The main problems for the symbol tables are: How to connect to the tooling API by using the WSC for example? How to compile all the containers (first mandatory step that is not the compilation by default)? How to get all the ExternalReferences and synthesize the results?

Andrew Fawcett solved all these problems with his tools.
https://github.com/afawcett/apex-codeanalysis/blob/master/src/main/java/canvas/ToolingAPI.java

Without the Andrew Fawcett's published works (often open source, excellent quality of code, the "reference"), many complicated problems will be much more difficult to solve with just the Salesforce documentation. 
 
sssssssssssssssssssssss ssssssssssssssssssssssss s
Unable to understand it especially without much java knowledge. Any videos or other resource to analyze unused code in apex, visualforce and other sfdc.com components.