Loading

Salesforce Apex: How to Find Unused Methods and Variables in code Using Tooling API SymbolTable

Data pubblicazione: May 30, 2026
Descrizione

When working with large Salesforce projects containing many Apex classes, Visualforce pages, components, and triggers, it is useful to identify unused methods and variables to maintain clean, efficient, and maintainable code.
This article explains how to use the Salesforce Tooling API's SymbolTable object to identify Apex methods that are defined in a class but not referenced by any other Apex class.

Risoluzione

How to Use Tooling API SymbolTable
The Salesforce Tooling API can be used to retrieve the SymbolTable for each Apex class in your org. The SymbolTable contains:

  • methods — all methods defined within that Apex class
  • externalReferences — references to methods from other classes that are consumed within the class

By scanning the methods defined in each Apex class's SymbolTable and comparing them against the externalReferences found across all other classes, you can identify methods that are defined but never called by any other Apex class — indicating they are potentially unused.

Third-Party Canvas App Option
A community-built canvas app is already available to automate this SymbolTable analysis. Note: This is a third-party, community-developed tool and is not supported by Salesforce. See Spring Cleaning Apex Code with the Tooling API for details.

Important Limitation
This approach only scans Apex classes. It will not detect declarative references to methods from Visualforce markup

Numero articolo Knowledge

000387972

 
Caricamento
Salesforce Help | Article