Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to find all unused Code

I need a tool I can run that will show me a list of unused methods, variables, properties, and classes. CSS classes would be an added bonus.

I heard FXCop can do this? or NDepend or something?

like image 548
PositiveGuy Avatar asked Nov 10 '09 15:11

PositiveGuy


People also ask

Where is the unused code in VSCode?

It is currently not possible to detect unused public methods in VSCode (you can check for updates here). However, if it's a private method, you can mark it as private and VSCode is able to look for whether it is used or not within the scope (although do remember: methods used in the HTML template are public).

Should unused code be removed?

“You should be constantly looking to improve your codebase, including removing dead code.” “If you have those processes in place, you should be constantly looking to improve your codebase, including removing dead code,” he said.


2 Answers

Look at ReSharper.

like image 169
Matt Grande Avatar answered Sep 22 '22 00:09

Matt Grande


Code Analysis in VSTS will generate warnings about this during the build process. You can set it up to treat Warnings As Errors.

like image 34
Winston Smith Avatar answered Sep 25 '22 00:09

Winston Smith