Unable to configure Sonarcloud for Flutter/Dart project

Error observed

The SonarCloud scan is not functioning as expected on pull requests. It fails to access the main branch, and the coverage of new lines of code is not determined. The pipeline completes successfully, but results do not seem to reflect the repository state accurately.

ALM used

GitHub

CI system used

GitHub Actions

Pipeline

Before this pipeline, tests and coverage report is generated.

name: Sonar

on:
  workflow_call:
    secrets:
      SONAR_TOKEN:
        required: true

jobs:
  Sonar:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4.1.0
        with:
          fetch-depth: 0
      - name: Download Test Artifact(s)
        uses: actions/download-artifact@v4
        with:
          name: test-artifact
      - name: SonarCloud Scan
        uses: sonarsource/sonarcloud-github-action@v3
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Languages of the repository

Flutter/Dart

SonarCloud properties

# Configuration file for SonarCloud

sonar.projectKey=xxxxxxxx
sonar.organization=xxxxxxxx

sonar.projectName=xxxxxxxxx
sonar.projectVersion=1.0

sonar.language=dart

sonar.tests=test/
sonar.dart.lcov.reportPaths=coverage/lcov.info
sonar.sourceEncoding=UTF-8

Steps to reproduce

  1. Implement the provided GitHub Actions pipeline for SonarCloud.
  2. Configure the project with the sonar-project.properties file.
  3. Trigger a pull request.

Potential workaround

No known workaround at this point.

Hi,

Welcome to the community!

Can you post your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

And as a side note, this does nothing and can be removed:

 
Ann

Hi @williamskaug,

sonarsource/sonarcloud-github-action doesn’t work properly with Dart (see message).

Please try the workaround provided in the message and tell us if the result has improved.

Also, SonarClound tutorials were supposed to be updated for Dart/Flutter projects; let us know if it still appears as the recommended way to analyze Dart/Flutter projects.

We plan to work on improving the situation soon and updating the action to be compatible with Dart/Flutter.

Best,
Margarita

1 Like