True or False:

When refactoring legacy methods (e.g. adding a parameter or deleting altogether), it is guaranteed not to break anything as long as I update every reference in the code base, based on a global find in org metadata for the method name that searches all classes and pages, given that the method's access modifier is public with no annotations, and is not a getter.

The no annotations bit seems to make searching more metadata types needless, since flows/processes require @InvocableMethod, JS static resources need @RemoteAction, aura bundles need @AuraEnabled, and integrations require REST annotations or WebService keyword.

I want to be defensive in my approach, but this legacy method already has 3 needless method overloads, and I feel like I'm sacrificing readability for (perhaps unjustified) precaution to add another overload. I want to be cautious but not overly cautious.


1 Answer 1


I'll paraphrase your question a bit:

If I have a method whose access is public or private, and it has no annotations, can I trust a global search on all classes and pages to find all calls to this method?

A word to the wise, pull down a fresh copy of your production code base before doing any such search. If you run it on stale metadata, then any assurance you have about the code base you do the work on is moot.

It's still not technically iron clad. A contrived example of a loophole would be an exposed UI that allows users to select a class name, method name, and arguments as needed, and then passes those inputs to the Tooling API to execute an anonymous script using those inputs. You would never be able to close such a gap, but that's not likely something you need to worry about.

That said, if your method has no annotations and has the public or private access modifier (not global or webservice), then searching through all classes and pages should suffice. Note, however, that a literal search isn't always the right way to go. For example, if your method is named getSomeStuff, you would need to search a page for someStuff.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .