当我试图发送带有sonar scanner的python项目时,它抛出了一个异常:
Caused by: java.lang.IllegalStateException: Unknown report version: 4.4.2.
This parser only handles version 1.".
在尝试介绍封面之前,项目是正常运行的,项目是python代码,报告是用django-nose
创建的。在
更多信息:
sonar-scanner -Dsonar.projectKey=nanas
-Dsonar.host.url=http://192.168.0.1:9001 -Dsonar.login=F00B4Z
我附加了sonar项目配置文件和由django-nose
生成的覆盖xml文件。在
例外:
^{pr2}$配置:
sonar.projectKey=nanas
sonar.projectName=Nanas
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=nucleo, app_administrador, app_cliente, app_gestor_de_citas, app_nana, app_test, django_gae_emailbackend
sonar.exclusions=**/tests/**, **/static/**/template/**, **/migrations/**, **/__pycache__/**, **/__init__.*
sonar.tests=xmlrunner/nosetests.xml
sonar.genericcoverage.reportPaths=xmlrunner/coverage.xml
sonar.python.coveragePlugin=cobertura
sonar.coverage.dtdVerification=false
覆盖率.xml页眉:
<?xml version="1.0" ?>
<coverage branch-rate="0" branches-covered="0" branches-valid="0" complexity="0" line-rate="0.5905" lines-covered="1142" lines-valid="1934" timestamp="1516639621366" version="4.4.2">
<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
我已经根据指示配置了扫描仪,并将插件更新到版本1.9,但现在它生成了一个行数错误。我已经搜索了几个网站寻找解决方案,几乎所有的事情都归结为添加一个空白行,但这并不起作用。在
运行测试:
nosetests --with-coverage --cover-package=app_administrador,app_cliente,app_nana,app_test,app_gestor_de_citas,nucleo --cover-erase --cover-xml --with-xunit --xunit-file=xmlrunner/nosetests.xml --cover-xml-file=xmlrunner/coverage.xml --attr=!pendiente --verbosity=1
运行声纳:
sonar-scanner -Dsonar.projectKey=nana -Dsonar.host.url=http://192.168.0.15:9001 -Dsonar.login=*********
声纳-项目.属性
sonar.projectKey=nanas
sonar.projectName=nanas
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=nucleo, app_administrador, app_cliente, app_gestor_de_citas, app_nana, app_test, django_gae_emailbackend
sonar.exclusions=**/tests/**, **/static/**/template/**, **/migrations/**, **/__pycache__/**, **/admin.py
sonar.tests=xmlrunner/nosetests.xml
sonar.python.coverage.reportPath=xmlrunner/coverage.xml
错误:
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Line 21 is out of range in the file app_administrador/middleware.py (lines: 19)
at org.sonar.api.internal.google.common.base.Preconditions.checkState(Preconditions.java:197)
Python插件
Sonapython嵌入了对覆盖率.py报告。 要启用它,您可以替换常规覆盖配置:
通过特定的Sonapython配置:
^{pr2}$有关详细信息,请参见Python Coverage Results Import
注意:Sonapython1.9中已经对覆盖率.py(直到4.4.2),如果您还不能下载SonarPython1.9,那么候选版本是here。在
我终于知道发生了什么事。似乎扫描仪混淆了不同django应用程序中的两个同名文件,因为每个应用程序在django nose的django设置中都被配置为“cover package”。在
显然,django nose将所有包根文件视为单个模块”。/“如果有重复的文件(例如:管理员py)只读取一个,但是当你把数据传递给python扫描仪时,它会尝试读取另一个,如果它们都有不同的行,就会引发冲突,我想如果它们碰巧有相同的行,那么在声纳覆盖的代码与行中的表示也将是错误的。在
更改前django nose生成的覆盖文件:
然后我们必须替换它(django设置):
^{pr2}$就这样:
变更后的覆盖率文件: 我们可以看到,模块中重复的每个文件都已经通过其源应用程序进行了区分。在
相关问题 更多 >
编程相关推荐