Question

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.

Was it helpful?

Solution

From the documentation:

Clones that are less than 10 statements long are not discovered by this command.

OTHER TIPS

VS2015 handles clones in exact/strong/medium/weak for 2 lines or more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top