Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration of Code Clones in Visual Studio 11

I really like the new built in feature of VS11 to find 'Code Clones' but there does not seem to be any way to configure it.

An example would be only show me exact clones of 5 lines or more.

Right now it gives Exact, Strong, Medium and Weak matches and it seems like they are for 10 lines or more. If I could configure this it would help work through the clones and it would find me those small methods that I am sure have been cut and pasted over the years.

UPDATE Here is the notes from the documentation for the Release Preview version about how to configure the ability to exclude generated files

To exclude files generated by T4 templates from code clone analysis

  1. Place the templates in a sub directory of the Visual Studio project. Name it, for example, GeneratedFiles.

  2. Add a new text file to the project, and change its name and extension to t4Exclusions.codeclonesettings

  3. Change the content of the file as follows:

<CodeCloneSettings> <Exclusions> <File>GeneratedFiles*.cs</File> </Exclusions> </CodeCloneSettings>

UPDATE - 08/27/2012 I found this in the Code Clone documentation, it was not there in the earlier versions. It is one way to find clones of less than 10 lines long.

To find clones of a particular code fragment

1. Highlight a fragment of code within a method or a get/set definition.

Note - You can find clones of statements, but not declarations such as field, method, or property signatures.

2. On the shortcut menu for the fragment, choose Find matching clones in solution.

Use this method when you want to know if there is a similar method or fragment already in existence in your solution.

like image 528
Scott Wylie Avatar asked Mar 12 '12 23:03

Scott Wylie


1 Answers

From the documentation:

Clones that are less than 10 statements long are not discovered by this command.
like image 50
demoncodemonkey Avatar answered Sep 20 '22 21:09

demoncodemonkey