设置检测重复的c#代码

本文关键字:代码 检测 设置 | 更新日期: 2023-09-27 17:50:55

我无法检测到sonarq中的重复代码我已经启动并运行Sonarqube 5.1,并安装了以下插件:

    c# [csharp] 4.0
  • Issue Assign [issueassign] 1.6
  • Issues Density [issuesdensity] 1.0
  • Java [Java] 3.0
  • JavaScript [JavaScript] 2.5
  • German Pack [l10nde] 1.1
  • Python [Python] 1.5
  • Redmine [Redmine] 0.2
  • ReSharper [ReSharper] 1.0
  • Git [scmgit] 1.0
  • Mercurial [scmcial] 1.1
  • Scm Stats [scmstats] 0.3.1
  • SVN [scmsvn] 1.0
  • TFS [scmtfs] 1.0
  • StyleCop [StyleCop] 1.1
  • Analysis Bootstrapper for Visual Studio Projects [visualstudio] 1.2
  • Web [Web] 2.3
  • XML [XML] 1.2

sonar-Project.properties:

sonar.projectKey=simplecalc
sonar.projectName=Simple Calc
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.visualstudio.enable=true
sonar.cs.vstest.reportsPaths=TestResults/*.trx
sonar.cs.dotcover.reportsPaths=dotCover.CalcLibrary.UnitTests.html
sonar.sources=.

设置检测重复的c#代码

解决!如源代码所示,有两个参数可以控制CPD传感器:

  • minimumLines代码

  • defaults minimumLines code

  • defaults和minimumTokens代码

这些必须调整以适应需要:

sonar.cpd.cs.minimumLines = 1
sonar.cpd.cs.minimumTokens = 1