Can findbugs detect unused public methods

后端 未结 8 1625
死守一世寂寞
死守一世寂寞 2020-12-19 04:45

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

8条回答
  •  無奈伤痛
    2020-12-19 05:28

    Removing unused code (including unused public methods) is one thing obfuscators do. The problem is that you can't really tell if a public method is used by just looking at the class that contains it. You need to look at the whole system that is going to run, because a public method might be called from everywhere.

    Running the obfuscator against the whole system (i.e. your code and all libraries used to run the system) can help find public methods that are never called (caveat: reflection can mess with that result, of course!).

提交回复
热议问题