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
Sowmya YakkalaSowmya Yakkala 

How to get unused Apex Methods Using Tooling Api in Salesforce

How can i find unused Apex class methods in Salesforce using Tooling Api For that i find some blogs and they were saying to install Git,Maven,Heroku for that i am using canvas Develpor guide and i was confused wheather i am going in right way or not. Can anyone tell me i am in right way or not and steps to find unused Apex methods.
Best Answer chosen by Sowmya Yakkala
VinayVinay (Salesforce Developers) 
Hi Sowmya,

The Tooling API can be used to retrieve the SymbolTable for each apex class. This Symbol Table will tell you the methods that are defined in the apex class, and the references to methods that are consumed in the externalReferences.

By scanning the methods and corresponding references in each apex classes symbol table you can find methods that aren’t called by other apex classes.

https://help.salesforce.com/articleView?id=000340130&type=1&mode=1

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks,
Vinay Kumar

All Answers

VinayVinay (Salesforce Developers) 
Hi Sowmya,

The Tooling API can be used to retrieve the SymbolTable for each apex class. This Symbol Table will tell you the methods that are defined in the apex class, and the references to methods that are consumed in the externalReferences.

By scanning the methods and corresponding references in each apex classes symbol table you can find methods that aren’t called by other apex classes.

https://help.salesforce.com/articleView?id=000340130&type=1&mode=1

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks,
Vinay Kumar
This was selected as the best answer
Sowmya YakkalaSowmya Yakkala
Hi Vinay ,
Thank u for the response.Can u plz provide me the link how to generate SymbolTable  for an Apex class.Thanks in advance.

Thanks,
Y.Sowmya.
VinayVinay (Salesforce Developers) 
Hi Sowmya,

You can't use Tooling API SOQL queries directly in Apex.

Check below link which gives you more information.

https://salesforce.stackexchange.com/questions/116165/symbol-table-from-apex-class?noredirect=1&lq=1

Thanks,
Vinay Kumar