Setup to detect duplicate C# code

浪尽此生 提交于 2019-12-14 04:21:28

问题


I fail to detect duplicate code in sonarq I've Sonarqube 5.1 up and running and following plugins installed:

  • 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
  • Motion Chart [motionchart] 1.7
  • Python [python] 1.5
  • Redmine [redmine] 0.2
  • ReSharper [resharper] 1.0
  • Git [scmgit] 1.0
  • Mercurial [scmmercurial] 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=.

回答1:


Solved! As seen in the source code there are two parameters to control the CPD sensor:

  • minimumLines code

  • defaults minimumLines code

  • defaults and minimumTokens code

Those must be adjusted to fit the needs:

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


来源:https://stackoverflow.com/questions/30484091/setup-to-detect-duplicate-c-sharp-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!