Is there a tool for finding redundancy through a set of library code (.net C #)?

Is there a tool for finding redundancy through a library code set (.net C #)?

The problem is that I have several .NET libraries, but they usually have many similar / duplicate "helper" or "utility" functions. Sometimes the code may not be completely utilitarian, but it follows similar patterns with a slightly different name.

Is there any tool that can identify these similarities and report them in the C # library package?

+6
source share
3 answers

Visual Studio 11 (currently only a preview) has this functionality. You can download the developer preview for free to check it out.

It's called Code Clone Analysis, and it scans your code for similarities and generates a report that differs from exact matches by likely matches.

Here you can find a small example.

+4
source

CodeRush now has built-in Duplicate Code. I do not know what your budget is for such a tool, but I will find the benefits of CodeRush / Refactor! more than offset the cost of a license.

+4
source

See our CloneDR tool for finding exact and near-space blocks of duplicated code in large bodies of source code.

CloneDR works by analyzing the source code using the compiler's external interface, building compiler data structures ("AST") that represent code and map trees. This means that it can find duplicates, despite layouts, line breaks or comments. The matching process can find code blocks that are similar in the sense that can be parameterized; it easily finds similar blocks with renamed variables or with statements or code blocks that have been replaced.

There are versions for many languages, including C #. An example C # clone detection report can be found on the website.

CloneDR is not a "development preview". I wrote one of the original articles on how to do this in 1998, and has been developing CloneDR since then; see Detecting Clones Using Abstract Syntax Trees . (The Microsoft Clone detector detects clones based on tokens rather than tree-based ones, and produces IMHO responses that are not so good, in fact, such detectors like tokens - that’s why I wrote the article).

+3
source

Source: https://habr.com/ru/post/903306/


All Articles