3 ms·
Ask HN: What are the best tools for dead code detection?
I work in some Java and Objective C code, and while the Android Studio/XCode don't complain, I suspect some ifs and else's are hit. Are there any tools that could instrument the code at runtime and say if certain code fragments are hit?
- HoppedUpMenace 11y agoOnly one I've come across is Dead Code Detector plugin for Netbeans, which worked really well for me when looking for unused anything anywhere.
- shoo 11y agoa crude way of looking at it would be to instrument the code to measure code coverage. some coverage tools support distinguishing which branches were executed and which were not (at a finer granularity than statement-level coverage). this may not be exactly what you want - it would tell you "the branches were not taken during this run of the program", but not "it is logically impossible for this branch to be taken for any run of the program"
- lsiebert 11y agoI often use the command line utility ag to see where a particular function or method might be called.