TeamCity On-Premises 2024.07 Help

Duplicates Finder (ReSharper)

The Duplicates finder (ReSharper) build runner, based on ReSharper Command Line Tools, is intended to catch similar code fragments and provide a report on the discovered repetitive blocks of C# and Visual Basic .NET code in Visual Studio 2003, 2005, 2008, 2010, 2012, 2013, and 2015 solutions.

Refer to Configuring Build Steps for a description of common build steps' settings. Refer to Container Wrapper to learn how you can run this step inside a container).

Sources

Option

Description

Include

Use newline-delimited Ant-like wildcards relative to the checkout root to specify the files to be included into the duplicates search.
Visual Studio solution files are parsed and replaced by all source files from all projects within a solution.
Example: src\MySolution.sln

Exclude

Enter newline-delimited Ant-like wildcards to exclude files from the duplicates search (for example, */generated{*}{}.cs). The entries should be relative to the checkout root.

JetBrains ReSharper Command Line Tools Settings

Option

Description

R# CLT Home Directory

Select the ReSharper Command Line Tools version.

You can check the installed JetBrains ReSharper Command Line Tools versions on the Administration | Tools page. If you want to run ReSharper duplicates using a specific ReSharper version (for example, to ensure it matches the version you have installed in Visual Studio), you can use this page to install another version of the tools and can change the default version to be used.

dupFinder Platform

Select the platform bitness of the dupFinder tool. By default, x64. The cross-platform duplicates finder is also supported in ReSharper 2020.2.1 or later.

Duplicate Searcher Settings

Option

Description

Code fragments comparison

Use these options to define which elements of the source code should be discarded when searching for repetitive code fragments. Code fragments can be considered duplicated, if they are structurally similar, but contain different variables, fields, methods, types or literals. Refer to the samples below:

Discard namespaces

If this option is checked, similar contents with different namespace specifications will be recognized as duplicates.

NLog.Logger.GetInstance().Log("abcd"); A.Log.Logger.GetInstance().Log("abcd");

Discard literals

If this option is checked, similar lines of code with different literals will be recognized as duplicates.

myStatusBar.SetText("Not Logged In"); myStatusBar.SetText("Logging In...");

Discard local variables

If this option is checked, similar code fragments with different local variable names will be recognized as duplicates.

int a = 5; a += 6; int b = 5; b += 6;

Discard class fields name

If this option is checked, the similar code fragments with different field names will be recognized as duplicates.

Console.WriteLine(myFoo); Console.WriteLine(myBar); ... where myFoo and myBar are declared in the containing class

Discard types

If this option is checked, similar content with different type names will be recognized as duplicates. These include all possible type references (as shown below):

Logger.GetInstance("text"); OtherUtility.GetInstance("text"); ... where Logger and OtherUtility are both type names (thus GetInstance is a static method in both classes) Logger a = (Logger) GetObject("object"); OtherUtility a = (OtherUtility) GetObject("object"); public int SomeMethod(string param); public void SomeMethod(object[] param);

Ignore duplicates with complexity lower than

Use this field to specify the lowest level of complexity of code blocks to be taken into consideration when detecting duplicates.

Skip files by opening comment

Enter newline-delimited keywords to exclude files that contain the keyword in the file's opening comments from the duplicates search.

Skip regions by message substring

Enter newline-delimited keywords that exclude regions that contain the keyword in the message substring from the duplicates search. Entering "generated code", for example, will skip regions containing "Windows Form Designer generated code".

Enable debug output

Check this option to include debug messages in the build log and publish the file with additional logs (dotnet-tools-dupfinder.log) as an artifact.

Additional dupFinder parameters

Specify newline-separated command line parameters to add to calling dupFinder.exe.

Build Failure Conditions

If a build has too many duplicates, you can configure it to fail by setting a build failure condition.

Last modified: 03 November 2024