SonarScanner 错误“文件中的行超出范围”

问题描述

所以我正在正常地做我的 django 项目,然后,当我重构 formulas.py 中的函数名称时,我突然从我的 SonarScanner 中得到了这个错误(仅此而已,我没有调整我的 sonar.properties 或我的 ci.yml 文件):

java.lang.IllegalStateException: Line 308 is out of range in the file dietela_quiz/formulas.py (lines: 306)

然后我决定添加更多空格,使其达到 308 行,但从那时起,错误仍然存​​在,并且当我添加更多空格甚至创建了一个虚拟函数(以合法地增加文件长度)时,错误模式是建立这样的:

java.lang.IllegalStateException: Line n+1 is out of range in the file dietela_quiz/formulas.py (lines: n)

其中 n 是 formulas.py 中的实际行数

这是我的 yml 文件:

stages:
  - test
  - sonar-scanner
  - deploy

UnitTest:
  image: python:3.6.5
  stage: test
  before_script:
    - pip install -r requirements.txt
    - python manage.py makemigrations
    - python manage.py migrate
    - python manage.py collectstatic --no-input
    - python manage.py runserver 8000 &
  when: on_success
  script:
    - echo "Starting linter..."
    - sh linter.sh
    - echo "Starting tests..."
    - coverage erase
    - DATABASE_URL=$TEST_DATABASE_URL coverage run --include="./dietela_quiz/*","./nutritionists/*","./dietela_program/*" manage.py test --keepdb
    - coverage xml -i
    - coverage report -m
  artifacts:
    paths:
      - coverage.xml

SonarScanner:
  image:
    name: addianto/sonar-scanner-cli:latest
    entrypoint: [""]
  stage: sonar-scanner
  script:
    - sonar-scanner
      -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube
      -Dsonar.login=$SONARQUBE_TOKEN
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
      -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY

DeploymentStaging:
  image: ruby:2.4
  stage: deploy
  before_script:
    - gem install dpl
    - wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
  script:
    - dpl --provider=heroku --app=$HEROKU_APPNAME --api-key=$HEROKU_APIKEY
    - export HEROKU_API_KEY=$HEROKU_APIKEY
    - heroku run --app $HEROKU_APPNAME migrate
  environment:
    name: staging
    url: $HEROKU_APP_HOST
  only:
    - staging

我该怎么办?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...