Activity Forums Salesforce® Discussions How can we find the unused method in apex class? Reply To: How can we find the unused method in apex class?

  • Parul

    Member
    September 21, 2018 at 1:19 pm

    Hi,

    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.

    Happily, Andrew Fawcett has already made such a tool as a canvas app. See Spring Cleaning Apex Code with the Tooling API.

    Note, as this is only scanning the apex classes it won’t detect declarative references from Visualforce markup.

    Thanks