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

  • Abhinav

    Member
    August 8, 2016 at 3:36 pm

    Hi Mohit,

    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.

  • Ravi

    Member
    August 9, 2016 at 7:57 am

    Here what I do when I need to find out unused method ,classes or any other component  in my org.

    I am assuming that you are using eclipse for your development and you have created  project for your org.

    Go ahead and press Ctrl + H ; it will open a popup , type the component you want to search(method).

    It will show where your components are used in your org ,so by this you can find out usability of your components in the org and proceed further as your requirement.

     

  • 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

  • shariq

    Member
    September 22, 2018 at 3:00 am

    Hi,

    The "Find Usages" functionality within IntelliJ's plugin called Illuminated Cloud. The downside to this is that Illuminated Cloud is not free, but it certainly does a bang up job.

    If you do choose to use Illuminated Cloud you can use this functionality by right clicking on any variable, property, method, or class name and choosing "Find Usages."

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs