4

Today I found tons of copy/paste code inside of if statements with one or two words changed. I changed the 35line beast into a 5 line easy to understand code.

I'm sure I'll find more of that in the codebase. Is there a tool I can use to find them? Its all in .NET written in C#

Kara
  • 6,115
  • 16
  • 50
  • 57
  • 1
    Have you seen this question: [What static analysis tools are available for C#?](http://stackoverflow.com/questions/38635/what-static-analysis-tools-are-available-for-c) – Roman Feb 09 '13 at 03:44
  • Bah, you just beat me to posting that link in my answer. Was looking for that exact one! – Jim D'Angelo Feb 09 '13 at 03:47

1 Answers1

9

I have run into the same issues and I use Visual Studio 2012's "Analyze Solution for Code Clones" in the "Analyze" menu. Often times it's not even a "cut and paste" job, but people adding their own methods to the code base without first checking to see if that code was already written. Sometimes it's a bunch of boilerplate code that could be abstracted with a generic or functional approach, too. (So, you have my sympathy!) Click here for more information on MSDN.

Jim D'Angelo
  • 3,952
  • 3
  • 25
  • 39