gemini-cli - 💡(How to fix) Fix Crash When pasting prompt [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#26177Fetched 2026-04-30 06:44:55
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
labeled ×1
RAW_BUFFERClick to expand / collapse

What happened?

bug-report-history-1777450965371.json

What did you expect to happen?

To give me an answer to this prompt: Tarea: Configurar cobertura de código Swift en SonarQube vía GitLab CI

Contexto

Tengo un proyecto iOS Swift (taponmobile-ios-app-gitlab) con un pipeline de GitLab CI que ejecuta sonar-scanner contra un SonarQube on-prem. El job se llama "Quality gate" y actualmente falla con QUALITY GATE STATUS: FAILED porque el análisis no incluye reporte de cobertura de código (Sonar reporta 0% en "new code" y el quality gate exige cobertura).

El log de Sonar muestra:

Sensor JaCoCo XML Report Importer [jacoco]
'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,...
No report imported, no coverage information will be imported by JaCoCo XML Report Importer

El proyecto sí tiene tests en iosApp/TapOnMobileTests, pero el pipeline no los ejecuta antes de Sonar y nunca genera un XML de cobertura compatible.

Objetivo

  1. Hacer que el job Quality gate ejecute los tests de iOS con cobertura activada.
  2. Convertir el .xcresult resultante a XML genérico de SonarQube.
  3. Pasar dicho XML al sonar-scanner para que reporte cobertura.
  4. Arreglar el warning Shallow clone detected añadiendo GITDEPTH: "0".
  5. Descomentar y configurar sonar.tests para distinguir test sources.

Estructura del proyecto (relevante)

.
├── .gitlab-ci.yml
├── sonar-project.properties
├── iosApp/
│   ├── TapOnMobile.xcworkspace
│   ├── TapOnMobile/                  código productivo
│   ├── TapOnMobileTests/             tests unitarios
│   ├── fastlane/
│   │   ├── Fastfile
│   │   └── testoutput/              se genera tras los tests
│   └── ...
└── scripts/                          CREAR si no existe
    └── xccov-to-sonarqube-generic.sh    CREAR

Ficheros actuales

.gitlab-ci.yml (estado actual del job a modificar)

stages:
  - analysis
  - quality
  - dependency-track

Quality gate:
  stage: quality
  only:
    - mergerequests
    - develop
    - feature/ci-branch-coverage
  variables:
    SDK: "sandbox"
  script:
    - |
      if [ -n "$CIMERGEREQUESTIID" ]; then
        echo "Fetching target branch $CIMERGEREQUESTTARGETBRANCHNAME..."
        git fetch origin $CIMERGEREQUESTTARGETBRANCHNAME
        SONARARGS="-Dsonar.pullrequest.key=$$CIMERGEREQUESTIID -Dsonar.pullrequest.branch=$$CIMERGEREQUESTSOURCEBRANCHNAME -Dsonar.pullrequest.base=$CIMERGEREQUESTTARGETBRANCHNAME"
      fi
    - sonar-scanner $SONARARGS
  tags:
    - mac-aws
  artifacts:
    paths:
      - iosApp/fastlane/testoutput

(El resto de jobs dependency-track y ai-code-review deben quedar SIN tocar.)

sonar-project.properties (estado actual)

sonar.projectKey=taponmobile-ios-app-sonarqube
sonar.projectName=taponmobile-ios-app-gitlab
sonar.qualitygate.wait=true
sonar.sources=iosApp/TapOnMobile
 sonar.tests=iosApp/TapOnMobileTests
sonar.sourceEncoding=UTF-8
sonar.host.url=https://sonarqube.kazan.myworldline.com/
sonar.plugins.downloadOnlyRequired=false
sonar.java.binaries=androidApp/build,TapOnMobileSDKLogger/build

Cambios requeridos

  1. Modificar sonar-project.properties para que quede así

    sonar.projectKey=taponmobile-ios-app-sonarqube sonar.projectName=taponmobile-ios-app-gitlab sonar.qualitygate.wait=true

    sonar.sources=iosApp/TapOnMobile sonar.tests=iosApp/TapOnMobileTests sonar.test.inclusions=iosApp/TapOnMobileTests//.swift

    sonar.sourceEncoding=UTF-8 sonar.host.url=https://sonarqube.kazan.myworldline.com/ sonar.plugins.downloadOnlyRequired=false sonar.java.binaries=androidApp/build,TapOnMobileSDKLogger/build

    Cobertura Swift en formato genérico de SonarQube sonar.coverageReportPaths=iosApp/sonarqube-generic-coverage.xml

    Excluir tests y previews del cálculo de cobertura sonar.coverage.exclusions=iosApp/TapOnMobileTests/,iosApp/TapOnMobile//Preview.swift,iosApp/TapOnMobile//Preview.swift

  2. Reemplazar el job Quality gate en .gitlab-ci.yml por:

    Quality gate: stage: quality only: - mergerequests - develop - feature/ci-branch-coverage variables: SDK: "sandbox" GITDEPTH: "0" evita el warning "Shallow clone detected" en Sonar script: 1) Ejecutar tests iOS con cobertura - cd iosApp - fastlane test 2) Convertir .xcresult -> XML genérico SonarQube - chmod +x ../scripts/xccov-to-sonarqube-generic.sh - bash ../scripts/xccov-to-sonarqube-generic.sh fastlane/testoutput/.xcresult > sonarqube-generic-coverage.xml - ls -lh sonarqube-generic-coverage.xml - cd .. 3) Lanzar sonar-scanner - | if [ -n "$CIMERGEREQUESTIID" ]; then echo "Fetching target branch $CIMERGEREQUESTTARGETBRANCHNAME..." git fetch origin $CIMERGEREQUESTTARGETBRANCHNAME SONARARGS="-Dsonar.pullrequest.key=$CIMERGEREQUESTIID
    -Dsonar.pullrequest.branch=$CIMERGEREQUESTSOURCEBRANCHNAME
    -Dsonar.pullrequest.base=$CIMERGEREQUESTTARGETBRANCHNAME" fi - sonar-scanner $SONARARGS tags: - mac-aws artifacts: when: always paths: - iosApp/fastlane/testoutput - iosApp/sonarqube-generic-coverage.xml

  3. Crear scripts/xccov-to-sonarqube-generic.sh con este contenido EXACTO

(script oficial de SonarSource: https://github.com/SonarSource/sonar-scanning-examples/blob/master/swift-coverage/swift-coverage-example/xccov-to-sonarqube-generic.sh)

!/usr/bin/env bash
set -euo pipefail

function convertfile {
  local xccovarchivefile="\$1"
  local filename="\$2"
  local xccovoptions="\$3"
  echo "  <file path=\"$filename\">"
  xcrun xccov view $$xccovoptions --file "$$filename" "$xccovarchivefile" | \
    sed -n '
    s/^ \([0-9][0-9]\): 0.$/    <lineToCover lineNumber="\1" covered="false"\/>/p;
    s/^ \([0-9][0-9]\): [1-9].$/    <lineToCover lineNumber="\1" covered="true"\/>/p
    '
  echo '  </file>'
}

function xccovtogeneric {
  echo '<coverage version="1">'
  for xccovarchivefile in "$@"; do
    if [[ ! -d $xccovarchivefile ]]; then
       xcresult bundle (Xcode 11+)
      xccovoptions="--archive"
    else
      xccovoptions=""
    fi
    xcrun xccov view $$xccovoptions --file-list "$$xccovarchivefile" | while read -r filename; do
      convertfile "$$xccovarchivefile" "$$filename" "$xccovoptions"
    done
  done
  echo '</coverage>'
}

xccovtogeneric "$@"

Permisos: chmod +x scripts/xccov-to-sonarqube-generic.sh

  1. Asegurar que iosApp/fastlane/Fastfile tiene un lane test con cobertura y result bundle

Si no existe o no está bien configurado, el lane debe quedar así (o equivalente):

lane :test do
  runtests(
    workspace: "TapOnMobile.xcworkspace",
    scheme: "TapOnMobile",
    codecoverage: true,
    resultbundle: true,
    outputdirectory: "fastlane/testoutput",
    devices: ["iPhone 15"]
  )
end

Importante: resultbundle: true es obligatorio para que se genere el .xcresult que el script convierte.

Criterios de aceptación

  1. El job Quality gate ejecuta tests antes de sonar-scanner.
  2. Se genera iosApp/sonarqube-generic-coverage.xml y se sube como artifact.
  3. En el log de sonar-scanner aparece Sensor Generic Coverage Report (o similar) importando cobertura, en lugar del mensaje "No report imported".
  4. En el dashboard de SonarQube del MR, la métrica Coverage on New Code ya no es 0%.
  5. El warning Shallow clone detected desaparece.
  6. Los demás jobs (ai-code-review, dependency-track) no se modifican.

Por favor

Aplica los cambios en .gitlab-ci.yml, sonar-project.properties, crea scripts/xccov-to-sonarqube-generic.sh y revisa/actualiza iosApp/fastlane/Fastfile. Muéstrame un diff resumen de cada fichero modificado/creado. Avísame si detectas que el scheme TapOnMobile no tiene los tests añadidos al Test Plan (es un fallo común que rompe codecoverage: true).

Client information

  • CLI Version: 0.40.0
  • Git Commit: 3d5bdc052
  • Session ID: ccfd8363-3107-4915-854a-fbf0570e255a
  • Operating System: darwin v25.9.0
  • Sandbox Environment: no sandbox
  • Model Version: auto-gemini-3
  • Auth Type: oauth-personal
  • Memory Usage: 262.3 MB
  • Terminal Name: Warp(v0.2026.04.27.15.32.stable_02)
  • Terminal Background: #31323f
  • Kitty Keyboard Protocol: Supported

Login information

API KEY

Anything else we need to know?

No response

extent analysis

TL;DR

To fix the issue, update the .gitlab-ci.yml and sonar-project.properties files, create the scripts/xccov-to-sonarqube-generic.sh script, and ensure the iosApp/fastlane/Fastfile has a test lane with code coverage and result bundle enabled.

Guidance

  • Update the sonar-project.properties file to include the sonar.test.inclusions and sonar.coverageReportPaths properties.
  • Modify the Quality gate job in .gitlab-ci.yml to execute tests with code coverage, convert the .xcresult file to a generic SonarQube coverage XML file, and pass the XML file to the sonar-scanner.
  • Create the scripts/xccov-to-sonarqube-generic.sh script with the exact contents provided.
  • Ensure the iosApp/fastlane/Fastfile has a test lane with codecoverage: true and resultbundle: true enabled.

Example

The iosApp/fastlane/Fastfile should have a lane similar to:

lane :test do
  runtests(
    workspace: "TapOnMobile.xcworkspace",
    scheme: "TapOnMobile",
    codecoverage: true,
    resultbundle: true,
    outputdirectory: "fastlane/testoutput",
    devices: ["iPhone 15"]
  )
end

Notes

The changes should be applied carefully to ensure that the other jobs (ai-code-review and dependency-track) are not modified.

Recommendation

Apply the workaround by updating the configuration files and creating the script, as this should fix the issue with code coverage reporting in SonarQube.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix Crash When pasting prompt [1 participants]