This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 181458 - Find unused public classes, methods, fields
Summary: Find unused public classes, methods, fields
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal with 11 votes (vote)
Assignee: Svata Dedic
URL:
Keywords:
: 35617 89809 197574 236496 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-03-03 00:18 UTC by _ gtzabari
Modified: 2017-01-30 14:43 UTC (History)
9 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2010-03-03 00:18:43 UTC
While there is no deterministic way to flag public classes, methods and fields are unused (they can be referenced by external projects) Netbeans should still provide a mechanism for doing so to help developers trim potentially unused code. Eclipse has a plugin that does this: http://www.ucdetector.org/

Justification: http://stackoverflow.com/questions/162551/how-to-find-unused-dead-code-in-java-projects
Comment 1 alied 2013-07-11 15:42:40 UTC
yes, this would be very useful.
I agree there is no way to absolutely detect unused code, but you can do it within certain scope (project, opened project, project hierarchy, package, you name it).
Comment 2 markiewb 2013-10-03 09:38:14 UTC
*** Bug 89809 has been marked as a duplicate of this bug. ***
Comment 3 markiewb 2013-10-03 09:38:35 UTC
*** Bug 236496 has been marked as a duplicate of this bug. ***
Comment 4 _ gtzabari 2015-01-02 09:00:10 UTC
Version is meant to indicate when the problem was first reported. Please don't update it to a newer value.
Comment 5 markiewb 2015-01-02 11:03:23 UTC
*** Bug 35617 has been marked as a duplicate of this bug. ***
Comment 7 iikku 2015-01-02 12:14:37 UTC
There's also 
Source -> Inspect 
with FindBugs -configuration, which will check for unused private methods:
http://findbugs.sourceforge.net/bugDescriptions.html#UPM_UNCALLED_PRIVATE_METHOD

However the dcd dead code detector does raise a lot more possible suspects and with a decent ui it could be a nice addition to nb.
Comment 8 _ gtzabari 2015-01-02 17:49:33 UTC
markiewb,

The plugin you referenced is listed for Netbeans 7.3. I don't think it'll work for the latest version.
Comment 9 markiewb 2015-01-02 18:21:50 UTC
(In reply to _ gtzabari from comment #8)
> markiewb,
> 
> The plugin you referenced is listed for Netbeans 7.3. I don't think it'll
> work for the latest version.

It works using NB 8.0.2. I tested it some minutes ago. AFAIK the plugin integration is very thin and uses only stable NB APIs. That the reason why you can often use NB plugins from 6.x-ages in NB 8.x.

If there is any bug contact Geertjan and he can fix it or he can give you access to the sources to fix it yourself.
Comment 10 _ gtzabari 2015-01-02 20:40:27 UTC
markiewb,

Thanks for the head's up. I'll check it out.
Comment 11 kap 2015-01-22 00:32:11 UTC
The plugin still works, however only up to java 1.7. I guess this is not a problem of the plugin but of the underlying Dead Code Detector
Comment 12 markiewb 2016-03-25 13:37:59 UTC
*** Bug 197574 has been marked as a duplicate of this bug. ***
Comment 13 jason3421 2017-01-30 14:43:02 UTC
I would *really* like it if Netbeans had first-class support for this, to include Java8 support. IntelliJ, Eclipse, and even Visual Studio all do this. Of those, Eclipse is the only one that needs a plugin to do so. Please consider this request Netbeans team, and thanks for making the best JAVA IDE out there!