C4tWithShell / community-rust

SonarQube plugin to analyze Rust files
GNU Lesser General Public License v3.0
121 stars 7 forks source link

Coverage don't showned #104

Open kambei opened 4 weeks ago

kambei commented 4 weeks ago

I have a Rust project in the root folder, and in a folder sonarqube inside the root I have this docker-compose:

services:

  sonarqube:
    image: sonarqube:community
    container_name: sonarqube
    ports:
      - "9000:9000"
    environment:
      SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonarqube
      SONAR_JDBC_USERNAME: sonarqube
      SONAR_JDBC_PASSWORD: sonarqube
    depends_on:
      - db
    volumes:
      - ./community-rust-plugin-0.2.4.jar:/opt/sonarqube/extensions/plugins/community-rust-plugin-0.2.4.jar
      - ./sonarqube-init.sh:/opt/sonarqube/init/sonarqube-init.sh
    entrypoint: >
      /bin/bash -c "
      bash /opt/sonarqube/init/sonarqube-init.sh &
      exec /opt/sonarqube/docker/entrypoint.sh"
    healthcheck:
        test: ["CMD", "curl", "-f", "http://localhost:9000"]
        interval: 30s
        timeout: 10s
        retries: 5

  db:
    image: postgres:13
    container_name: sonarqube_db
    environment:
      POSTGRES_USER: sonarqube
      POSTGRES_PASSWORD: sonarqube
      POSTGRES_DB: sonarqube

  ### BEFORE SCANNER GENERATE THE clippy.json, sonar-issues.json and the lcov.info:
  ### commands to run before scanner:
  ### cargo tarpaulin --out Xml
  ### cargo clippy --message-format=json > clippy.json
  ### cargo sonar --clippy --clippy-path clippy.json
  ### RUSTC_BOOTSTRAP=1 cargo test -- -Z unstable-options --format json --report-time | cargo2junit > results.xml
  scanner:
    image: sonarsource/sonar-scanner-cli:latest
    container_name: scanner
    environment:
      - SONAR_HOST_URL=http://sonarqube:9000
      - SONAR_SCANNER_OPTS=-Dsonar.working.directory=/tmp/.scannerwork
      - community.rust.clippy.reportPaths=/sonar/clippy.json
      - sonar.externalIssuesReportPaths=/sonar/sonar-issues.json
      - community.rust.cobertura.reportPaths=/sonar/cobertura.xml
      - community.rust.test.reportPath=/sonar/results.xml
    depends_on:
      sonarqube:
        condition: service_healthy
    volumes:
      - ../src:/usr/src
      - ../clipy.json:/sonar/clippy.json
      - ../sonar-issues.json:/sonar/sonar-issues.json
      - ../cobertura.xml:/sonar/cobertura.xml
      - ../test-report.xml:/sonar/results.xml
    working_dir: /usr/src
    entrypoint:  >
      /bin/bash -c "sonar-scanner -Dsonar.projectKey=RustGeoCraft -Dsonar.login=admin -Dsonar.password=admin"

The coverage is not showned in SonarQube.

Is it my fault?

Other things showned fine.

kambei commented 4 weeks ago

this is my cobertura.xml:

<?xml version="1.0"?><coverage lines-covered="50" lines-valid="618" line-rate="0.08090614886731391" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0" version="1.9" ...
C4tWithShell commented 3 weeks ago

I will check. There may be a problem with parsing cobertura report. Even through I fixed it in 0.2.3

You can check if lcov format will be displayed correctly

kambei commented 3 weeks ago

I tried Lcov format before Cobertura. Same result. Not showned. Thanks.

elegoff commented 2 weeks ago

Adding a -X option at the end of your sonar-scanner command call should trigger verbose logs (generating extra log lines with "DEBUG" )

That may help understand the root cause

Most of the time, unreported coverage issues caused by either:

You may share the verbose logs here or privately for our review

Feel free to redact any sensitive content