Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage don't showned #104

Open
kambei opened this issue Aug 14, 2024 · 4 comments
Open

Coverage don't showned #104

kambei opened this issue Aug 14, 2024 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@kambei
Copy link

kambei commented Aug 14, 2024

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
Copy link
Author

kambei commented Aug 14, 2024

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 C4tWithShell self-assigned this Aug 20, 2024
@C4tWithShell
Copy link
Owner

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
Copy link
Author

kambei commented Aug 20, 2024

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

@elegoff
Copy link
Collaborator

elegoff commented Aug 29, 2024

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:

  • the coverage report is not found at the time of the sonar scan
    Or
  • the coverage report is found but it doesn't match the current state of the scanned source code (i e mismatched line numbers)

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

Feel free to redact any sensitive content

@C4tWithShell C4tWithShell added the question Further information is requested label Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants