Remove all unused code based off of a single Main method

Viewed 156

Do you know any way to find (un)used code from the perspective of a specific main method (or what IntelliJ calls an entry point)?

The background is that we have a big java project in which we have custom code for several clients. Sometimes we give clients the current state of the project in source form but would obviously want to remove the parts which only concern other clients. We have a Main file for each client so it should be possible to follow imports from there to find exactly the files relevant to each client.

I was hoping to be able to run intellij's code inspection on a single entry point but was unable to find anything. I'm open to any solution though.

1 Answers

You could remove all other entry points and run intellij's code inspection again to detect unused code. Now that you have only one entry point it should be able to tell you what code is unused. With that knowledge you can revert you changes and remove this code.

Hope that helps.

Related