Redundancy check

Are there any tools out there that can find any private functions without any links? (Redundant functions)

The reason is that the function could have been created and called from multiple scopes, but as the project expands and grows, these two calls can be removed and replaced with a better alternative. But the method can still remain. I was wondering if there are any handy tools that will look at the code, define private functions and check if they have any links, if not, inform the user of the situation.

It wouldn't be too difficult to create one yourself, but I was wondering if there are any applications available that could do this with files containing code?

My code is in C #, but I can imagine this question covers a lot of coding languages.

+2


source to share


4 answers


If your code has Unit Tests (it does, right? ;-), then running NCover will allow you to define methods that don't call anywhere. If you don't have unit tests, then this is a good reason to start building one.



In general, I suspect that code coverage tools work well for most languages.

+2


source


ReSharper is doing the job.



+3


source


Eclipse does this automatically for Java, not sure if you can have the same for C #.

0


source


Another question might even be "Will the C # compiler compile private methods that are not actually used?"

My guess won't be, but you never know!

EDIT:

In fact, I think it would be difficult to tell where the method is being used. It can be private, but it can still be used as event handlers. Impossible to verify, but I'm sure this aspect will make it a little more difficult.

0


source







All Articles