Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can findbugs detect unused public methods

Is it possible to detect unused methods in a source tree using FindBugs? I see some posts on SO where users are claiming to do that, some others asking how to do this in FB and others where they claim FB cannot do this.

Does anyone know for sure how this is done? I am only interested in methods that are not explicitly called from elsewhere, I don't care about reflection.

like image 881
Miserable Variable Avatar asked Jan 18 '11 06:01

Miserable Variable


People also ask

Which tool can be used to identify dead unused code?

UCDetector (Unnecessary Code Detector) is a eclipse PlugIn tool to find unnecessary (dead) public java code. For example public classes, methods or fields which have no references.

What is the use of FindBugs?

FindBugs is an open source tool used to perform static analysis on Java code. In this article, we're going to have a look at setting up FindBugs on a Java project and integrating it into the IDE and the Maven build.

Where is the unused code in Visual Studio code?

To find unused members with a Code Analysis Ruleset, from the Visual Studio menu select File -> New -> File… -> General -> Code Analysis Rule Set. Uncheck all the rules. There are many rules we don't care about right now – and some we probably won't ever care about.


2 Answers

as a member of the FindBugs team I can tell you that unfortunately FindBugs does not do this. If you search through the bug patterns on our website, the only mentions of "unused" detectors is for unused fields.

like image 59
Keith Avatar answered Nov 06 '22 05:11

Keith


I have a project i'm currently working on that does just this.... It's very early on tho, so probably a bunch of bugs left:

https://github.com/mebigfatguy/deadmethods

like image 23
MeBigFatGuy Avatar answered Nov 06 '22 05:11

MeBigFatGuy