【问题标题】:Python | Error during SonarQube Scanner execution | Line 3832 is out of range in the file .py蟒蛇 | SonarQube Scanner 执行期间出错 |第 3832 行超出文件 .py 的范围
【发布时间】:2019-02-13 11:18:27
【问题描述】:

以下是我的 sonar.properties 文件:-

sonar.projectKey=code
sonar.projectName=PROJECT
sonar.projectVersion=0.0.1
sonar.sources=code
sonar.python.coverage.reportPath=code/coverage*.xml
sonar.python.coveragePlugin=cobertura
sonar.python.xunit.reportPath=TEST*.xml
sonar.sourceEncoding=UTF-8
sonar.pli.marginLeft=2
sonar.pli.marginRight=0

下面是我正在执行的命令:-

$HOME/sonar-scanner-3.2.0.1227-linux/bin/sonar-scanner -Dsonar.verbose=false -Dsonar.projectKey=code -Dproject.settings=code/devops/sonar.properties -Dsonar.host.url=https://mysonar.net -Dsonar.login=$USERNAME -Dsonar.password=$PASSWORD

错误日志:-

INFO: Python test coverage
INFO: Parsing report '/data/jenkins/workspace/master-ci/code/coverage.xml'
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 9.052s
INFO: Final Memory: 15M/397M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Line 3832 is out of range in the file code/src/driver.py (lines: 3831)
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?

Sonarqube 版本:- 版本 7.1 (build 11001)LGPL v3Community 声纳扫描仪:- 3.2.0.1227

【问题讨论】:

  • 您能否更新您的帖子以澄清您的问题?
  • 我认为这是旧 scm 客户端版本的原因。删除文件,再次提交。现在应该过去了。

标签: sonarqube sonarscanner


【解决方案1】:

1- 添加一个空格。 (在coverage.xml 文件的底部)。这适用于旧的 pytest 测试。

2- 在另一个项目中,我更新了以下包:pytest、pytest-cov 和 coverage,这是最新版本。 (像魅力一样工作)。

这里有个问题:更新到最新的 pytest 版本时,您可能会发现 conftest.py 不再存在的方法。例如:get_marker 可以用新的 get_closest_marker 代替。或保留字如“请求”。对于最新的情况,您可以重命名名为 request 的方法。

【讨论】:

    猜你喜欢
    • 2016-07-05
    • 2021-09-25
    • 2017-07-08
    • 2017-03-28
    • 2017-02-06
    • 2018-03-03
    • 1970-01-01
    • 2017-10-11
    相关资源
    最近更新 更多