Sonarqube 如何解决此重复资源错误?

Sonarqube 如何解决此重复资源错误?,sonarqube,sonar-runner,Sonarqube,Sonar Runner,我有一个用coffeescript编写的nodejs项目,我使用sonarjavascript插件进行分析 我把我所有的源代码都放在一个名为“src”的文件夹中,把测试放在一个名为“test”的文件夹中 测试文件与源文件具有相同的名称 当我运行测试时 coffescript被编译成javascript并复制到“lib/src”和“lib/test” 然后检测javascript的覆盖率,并将其复制到“lib-cov/lib/src”和“lib-cov/lib/test”(实际上只检测src,测

我有一个用coffeescript编写的nodejs项目,我使用sonarjavascript插件进行分析

我把我所有的源代码都放在一个名为“src”的文件夹中,把测试放在一个名为“test”的文件夹中

测试文件与源文件具有相同的名称

当我运行测试时

  • coffescript被编译成javascript并复制到“lib/src”和“lib/test”
  • 然后检测javascript的覆盖率,并将其复制到“lib-cov/lib/src”和“lib-cov/lib/test”(实际上只检测src,测试只是再次复制以维护相对路径)
在对插入指令的代码运行测试后,我得到两个报告“reports/lcov.info”和“reports/TEST all.xml”

这适用于我的一个项目,但在另一个项目中,我从两个源文件中获得重复的资源错误(我无法找出它们的特殊之处)

“sonar project.properties”如下所示:

sonar.projectKey=ddm:ddm-server
sonar.projectName=D4A Dependency Manager Server
sonar.projectVersion=1.0

sonar.sources=lib/src
sonar.exclusions=index.js
sonar.language=js

sonar.javascript.jstestdriver.reportsPath=reports
sonar.javascript.lcov.reportPath=reports/lcov.info  
“lib/src”目录中的文件是(没有子目录):

  • Archive.js
  • Get.js
  • index.js
  • Library.js
  • Post.js
  • Registry.js
  • Version.js
只有“Archive.js”和“Post.js”会导致问题

并导致以下错误:

ERROR: Caused by: Duplicate source for resource: org.sonar.api.resources.File@16d828ef[key=Archive.js,dir=<null>,filename=Archive.js,language=JavaScript]
错误:原因:资源的源重复:org.sonar.api.resources。File@16d828ef[key=Archive.js,dir=,filename=Archive.js,language=JavaScript]
如果我排除了“Archive.js”和“Post.js”,一切正常-这些名字有什么特别之处吗

仅供参考:Jenkins的sonar runner的完整输出为:

[DDM_SERVER_CONTINUOUS_BUILD_AND_TEST] $ /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner_2.3/sonar-runner-2.3/bin/sonar-runner -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.url=jdbc:mysql://sonar.lgcoreapps.com:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8 ******** ******** -Dsonar.host.url=http://sonar.lgcoreapps.com ******** ******** -Dsonar.projectBaseDir=<http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/> -Dsonar.exclusions=index.js
SonarQube Runner 2.3
Java 1.7.0_09-icedtea Oracle Corporation (64-bit)
Linux 2.6.32-358.el6.x86_64 amd64
INFO: Runner configuration file: /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner_2.3/sonar-runner-2.3/conf/sonar-runner.properties
INFO: Project configuration file: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/sonar-project.properties>
INFO: Default locale: "en_US", source code encoding: "US-ASCII" (analysis is platform dependent)
INFO: Work directory: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/.sonar>
INFO: SonarQube Server 3.5.1
13:46:58.260 INFO  - Load batch settings
13:46:58.349 INFO  - User cache: /home/jenkins/.sonar/cache
13:46:58.351 INFO  - Install plugins
13:46:59.109 INFO  - -------------  Executing Project Scan
13:46:59.750 INFO  - Install JDBC driver
13:46:59.754 INFO  - Apply project exclusions
13:46:59.758 INFO  - Create JDBC datasource for jdbc:mysql://sonar.lgcoreapps.com:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8
13:47:00.110 INFO  - Initializing Hibernate
13:47:03.520 INFO  - -------------  Inspecting D4A Dependency Manager Server
13:47:03.525 INFO  - Load module settings
13:47:04.145 INFO  - Quality profile : [name=Sonar way,language=js]
13:47:04.171 INFO  - Excluded sources: 
13:47:04.172 INFO  -   index.js
13:47:04.172 INFO  - Excluded tests: 
13:47:04.172 INFO  -   **/package-info.java
13:47:04.203 INFO  - Configure Maven plugins
13:47:04.309 INFO  - Compare to previous analysis (2014-02-07)
13:47:04.335 INFO  - Compare over 5 days (2014-02-02, analysis of 2014-02-07 12:04:17.0)
13:47:04.352 INFO  - Compare over 30 days (2014-01-08, analysis of 2014-02-07 12:04:17.0)
13:47:04.654 INFO  - Base dir: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/>
13:47:04.654 INFO  - Working dir: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/.sonar>
13:47:04.654 INFO  - Source dirs: <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/lib/src>
13:47:04.654 INFO  - Source encoding: US-ASCII, default locale: en_US
13:47:04.676 INFO  - Sensor JavaScriptSourceImporter...
13:47:04.797 INFO  - Sensor JavaScriptSourceImporter done: 121 ms
13:47:04.797 INFO  - Sensor JavaScriptSquidSensor...
13:47:05.858 INFO  - Sensor JavaScriptSquidSensor done: 1061 ms
13:47:05.858 INFO  - Sensor LCOVSensor...
13:47:05.859 INFO  - Analysing <http://jenkins.lgcoreapps.com/job/DDM_SERVER_CONTINUOUS_BUILD_AND_TEST/ws/reports/lcov.info>
13:47:05.902 INFO  - Sensor LCOVSensor done: 44 ms
13:47:05.903 INFO  - Sensor JsTestDriverSensor...
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 8.617s
Final Memory: 9M/28M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Duplicate source for resource: org.sonar.api.resources.File@563e2119[key=Archive.js,dir=<null>,filename=Archive.js,language=JavaScript]
ERROR: 
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
[DDM\u服务器\u连续\u构建和\u测试]$/home/jenkins/tools/hudson.plugins.sonar.sonarrunner安装/sonar_Runner_2.3/sonar-Runner-2.3/bin/sonar-Runner-Dsonar.jdbc.driver=com.mysql.jdbc.driver-Dsonar.jdbc.url=jdbc:mysql://sonar.lgcoreapps.com:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8 **************-Dsonar.host.url=http://sonar.lgcoreapps.com **************-Dsonar.projectBaseDir=-Dsonar.exclusions=index.js
SonarQube跑步者2.3
Java 1.7.0_09-icedtea Oracle Corporation(64位)
Linux 2.6.32-358.el6.x86_64 amd64
信息:转轮配置文件:/home/jenkins/tools/hudson.plugins.sonar.sonarrunner安装/sonar\u Runner\u 2.3/sonar-Runner-2.3/conf/sonar-Runner.properties
信息:项目配置文件:
信息:默认区域设置:“en_US”,源代码编码:“US-ASCII”(分析取决于平台)
信息:工作目录:
信息:SonarQube服务器3.5.1
13:46:58.260信息-加载批次设置
13:46:58.349信息-用户缓存:/home/jenkins/.sonar/cache
13:46:58.351信息-安装插件
13:46:59.109信息-----------正在执行项目扫描
13:46:59.750信息-安装JDBC驱动程序
13:46:59.754信息-应用项目排除
13:46:59.758信息-为JDBC创建JDBC数据源:mysql://sonar.lgcoreapps.com:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8
13:47:00.110信息-初始化休眠
13:47:03.520信息-----------正在检查D4A依赖项管理器服务器
13:47:03.525信息-加载模块设置
13:47:04.145信息-质量概况:[名称=声纳方式,语言=js]
13:47:04.171信息-排除的来源:
13:47:04.172信息-index.js
13:47:04.172信息-排除的测试:
13:47:04.172信息-**/package-INFO.java
13:47:04.203信息-配置Maven插件
13:47:04.309信息-与之前的分析进行比较(2014-02-07)
13:47:04.335信息-5天比较(2014-02-02,2014-02-07 12:04:17.0分析)
13:47:04.352信息-30天比较(2014-01-08,2014-02-07 12:04:17.0分析)
13:47:04.654信息-基本目录:
13:47:04.654信息-工作目录:
13:47:04.654信息-源目录:
13:47:04.654信息-源编码:US-ASCII,默认区域设置:en_-US
13:47:04.676信息-传感器JavaScriptSourceImporter。。。
13:47:04.797信息-传感器JavaScriptSourceImporter完成:121毫秒
13:47:04.797信息-传感器JavaScriptSquid传感器。。。
13:47:05.858信息-传感器JavaScriptSquid传感器完成时间:1061毫秒
13:47:05.858信息-传感器LCOVSensor。。。
13:47:05.859信息-分析
13:47:05.902信息-传感器LCOV传感器完成:44毫秒
13:47:05.903信息-传感器JsTestDriverSensor。。。
信息:------------------------------------------------------------------------
信息:执行失败
信息:------------------------------------------------------------------------
总时间:8.617s
最终内存:9M/28M
信息:------------------------------------------------------------------------
错误:执行Sonar runner时出错
错误:无法执行声纳
错误:原因:资源的源重复:org.sonar.api.resources。File@563e2119[key=Archive.js,dir=,filename=Archive.js,language=JavaScript]
错误:
错误:要查看错误的完整堆栈跟踪,请使用-e开关重新运行SonarQube Runner。
错误:使用-X开关重新运行SonarQube Runner以启用完全调试日志记录。
生成步骤“调用独立声纳分析”将生成标记为失败
编辑:在确认未提交测试报告时分析完成ok后,这里是reports目录中的test-all.xml,以防它也提供线索

<testsuite name="Mocha Tests" tests="36" failures="0" errors="0" skipped="0" timestamp="Fri, 07 Feb 2014 10:23:12 GMT" time="1.073">
<testcase classname="Archive" name="should respond with 404 Not Found if pathInfo is not &quot;/&quot; or &quot;&quot;" time="0.005"/>
<testcase classname="Archive when the archive does not exist" name="should respond with 404 not Found" time="0.002"/>
<testcase classname="Archive when the archive exists" name="should respond with the archive" time="0.004"/>
<testcase classname="Get with an empty repository" name="should respond with an empty list of libraries" time="0.003"/>
<testcase classname="Get with a single library in the repository" name="should respond with a single entry list of libraries" time="0.002"/>
<testcase classname="Get with a multiple libraries in the repository" name="should respond with a list of libraries" time="0.004"/>
<testcase classname="Get with a multiple libraries in the repository" name="should prepend the root path to library paths correctly" time="0.001"/>
<testcase classname="Get with a multiple libraries in the repository" name="should pass requests with pathInfo not equal to &quot;/&quot; or &quot;&quot; to a Library instance" time="0.001"/>
<testcase classname="Library with an empty repository" name="should respond with 404 not Found" time="0.003"/>
<testcase classname="Library with an empty library (no versions)" name="should respond with an empty list of versions" time="0.003"/>
<testcase classname="Library with a single version" name="should respond with a single entry list of versions" time="0.002"/>
<testcase classname="Library with multiple versions" name="should respond with a list of versions" time="0.002"/>
<testcase classname="Library with multiple versions" name="should prepend the root path to library paths correctly" time="0.002"/>
<testcase classname="Library with multiple versions" name="should pass requests with pathInfo not equal to &quot;/&quot; or &quot;&quot; to a Version instance" time="0.001"/>
<testcase classname="Post" name="should respond with 400 Bad Request if the name is not specified" time="0.001"/>
<testcase classname="Post" name="should respond with 400 Bad Request if the version is not specified" time="0.001"/>
<testcase classname="Post" name="should respond with 415 Unsupported Media Type if the content-type is not application/octet-stream" time="0.001"/>
<testcase classname="Post" name="should respond with a new resource on success and write the archive and dependencies to the file system" time="0.015"/>
<testcase classname="Post" name="should respond with 400 Bad Request if dependencies are specified in an invalid format" time="0.005"/>
<testcase classname="Post" name="should add the dependencies to the new resource if present in the headers" time="0.015"/>
<testcase classname="Post" name="should prepend the root path to library paths correctly" time="0.011"/>
<testcase classname="Post" name="should respond with 405 Method Not Allowed if pathInfo is not &quot;/&quot; or &quot;&quot;" time="0.001"/>
<testcase classname="Registry GET" name="should be handled by an instance of Get" time="0.001"/>
<testcase classname="Registry POST" name="should be handled by an instance of Post" time="0"/>
<testcase classname="Registry UNKNOWN" name="should respond with 405 Method Not Allowed" time="0"/>
<testcase classname="Version when the version does not exist" name="should respond with 404 not Found" time="0.003"/>
<testcase classname="Version when the version exists" name="should respond with the version details and an empty list of dependencies" time="0.002"/>
<testcase classname="Version when the version exists" name="should pass requests with pathInfo equal to &quot;/archive&quot; to an Archive instance" time="0.001"/>
<testcase classname="Version when the version exists" name="should respond with 404 Not Found if pathInfo is not &quot;/&quot; or &quot;&quot; or &quot;/archive&quot;" time="0"/>
<testcase classname="Version when the version exists with a dependencies.json file" name="should respond with the list of dependencies" time="0.005"/>
<testcase classname="Version when the version exists with a dependencies.json file" name="should prepend the root path to library paths correctly" time="0.004"/>
<testcase classname="index with an empty repository GET &quot;/&quot;" name="should return an empty list of libraries" time="0.022"/>
<testcase classname="index with an empty repository after posting a library to &quot;/&quot; GET &quot;/&quot;" name="should respond with a single entry list of libraries" time="0.005"/>
<testcase classname="index with an empty repository after posting a library to &quot;/&quot; GET &quot;/library&quot;" name="should respond with a single entry list of versions" time="0.005"/>
<testcase classname="index with an empty repository after posting a library to &quot;/&quot; GET &quot;/library/0.0.0&quot;" name="should respond with the library resource" time="0.009"/>
<testcase classname="index with an empty repository after posting a library to &quot;/&quot; GET &quot;/library/0.0.0/archive&quot;" name="should respond with the library archive" time="0.006"/>
</testsuite>

因此,确认问题是由包含镜像源文件名的类名的测试报告引起的。我面临着要么重组测试,要么使用不同的摩卡记者的选择。据我所知,默认的mocha xunit reporter误用了classname字段(至少在BDD测试中是这样),而对我的测试结构所做的使其正常工作的更改对我来说是不可接受的


解决方案是实施并使用npm注册表中提供的现在可用的日志

您能提供完整的日志吗?问题中添加了ok。您能确认如果您从sonar-project.properties文件中删除“sonar.javascript.jstestdriver.reportsPath=reports”,分析会成功吗?谢谢,是的,它现在可以工作了,但是