Remove all unused code based off of a single Main method

63
July 02, 2019, at 00:50 AM

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.

Answer 1

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.

READ ALSO
OOP in Java: problem with constructor and methods

OOP in Java: problem with constructor and methods

I am new to Java and I am trying to write a class with constructors and methods that adds and divides two numbers, and also compares if one object is larger or equal than the otherBut I am getting an error: The method plus(int) in the type Compare is not applicable...

133
Understanding class members behavior Polymorphism

Understanding class members behavior Polymorphism

I'm facing some difficulties while trying to understand, what actually happens when we initiate an instance of a child class

77
Websphere Appserver v9 test Data Source connection fails

Websphere Appserver v9 test Data Source connection fails

I have configured a sybase datasource on websphere applicaiton server 9 installed on Linux,and trying to test itBut it fails with below exception

110
How to create gradle project with multiple root project in spring boot

How to create gradle project with multiple root project in spring boot

So the idea is to add a new gradle project in hierarchy, at root levelAll spring-boot sub modules will extend its build

133