sonar-flutter icon indicating copy to clipboard operation
sonar-flutter copied to clipboard

Cannot start flutter analyse, dart analyse nor dartanalyzer -h

Open KaioOCarvalho opened this issue 3 years ago • 3 comments

Our team is using SonarQube 9.3.0, running on a Ubuntu 20.04 AWS machine and I've added the plugin sonar-flutter-plugin-0.4.0.jar to the plugins folder. We have a mobile flutter project. By the way, our Java is 11.

I'm trying to use it with GitHub, but on every PR, it was showing no code problems. I then checked the terminal on GitHub and saw this:

INFO: Running 'flutter analyze'...

ERROR: org.buildobjects.process.StartupException: Could not startup process 'flutter analyze'.

java.io.IOException: org.buildobjects.process.StartupException: Could not startup process 'flutter analyze'.

And a few lines below I've got this:

Caused by: java.io.IOException: Cannot run program "flutter": error=2, No such file or directory

So I think SonarQube is not finding my flutter. But when I run the following, as you can see, I have flutter and dart installed and on my path, and also Java.

xxxx@ip-xxx-xx-xx-xx:~$ which flutter
/snap/bin/flutter
xxxx@ip-xxx-xx-xx-xx:~$ which dart
/usr/bin/dart
xxxx@ip-xxx-xx-xx-xx:~$ which java
/usr/bin/java
xxxx@ip-xxx-xx-xx-xx:~$ java --version
openjdk 11.0.14.1 2022-02-08
OpenJDK Runtime Environment (build 11.0.14.1+1-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.14.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)

Here is my config files:

.github/workflows/build.yml

name: Build
on:
  push:
    branches: [master, develop] # or the name of your main branch
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: sonarsource/sonarqube-scan-action@master
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
      # If you wish to fail your job when the Quality Gate is red, uncomment the
      # following lines. This would typically be used to fail a deployment.
      # We do not recommend to use this in a pull request. Prefer using pull request
      # decoration instead.
      # - uses: sonarsource/sonarqube-quality-gate-action@master
      #   timeout-minutes: 5
      #   env:
      #     SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

sonar-project.properties

# Project identification
sonar.projectKey=my_key

# Source code location.
# Path is relative to the sonar-project.properties file. Defaults to .
# Use commas to specify more than one folder.
sonar.sources=proj/lib    
# sonar.tests=test

# Encoding of the source code. Default is default system encoding.
sonar.sourceEncoding=UTF-8

# Allows reuse of an existing analyzer report
# sonar.dart.analysis.reportPath=

# Analyzer mode
# Can be:
# - flutter (flutter analyze) - default
# - dart (dart analyze)
# - legacy (dartanalyzer)
# sonar.flutter.analyzer.mode= 

Changing the sonar.flutter.analyzer.mode to dart or legacy just yielded the same problem for dartanalyser -h and dart analyse.

I'm not sure if this is actually a bug, but I've been trying for days to do it, and I've searched a lot.

KaioOCarvalho avatar Apr 26 '22 13:04 KaioOCarvalho

have the same issue...

hlebmymo avatar May 06 '22 10:05 hlebmymo

Let's try to use it. Seems like this case works.

name: Sonar
on:
  workflow_dispatch:
  push:
  branches: 
    - dev
 
jobs:

sonarqube:

  runs-on: ubuntu-latest

  steps:

  - name: Checkout the code
    uses: actions/checkout@v2

  - name: Install and set Flutter version
    uses: subosito/flutter-action@v2
    with:
      flutter-version: '2.10.3'
      channel: 'stable'
    
  - name: Run Flutter doctor
    run: |
      flutter doctor -v
                   
  - name: Sonar-scanner
    env:
      SONAR_SCANNER_VER: sonar-scanner-cli-4.7.0.2747-linux
      SONAR_SCANNER_PATH: sonar-scanner-4.7.0.2747-linux/bin
    run: |
      wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
      unzip sonar-scanner-cli-4.7.0.2747-linux.zip
      $SONAR_SCANNER_PATH/sonar-scanner -v
      $SONAR_SCANNER_PATH/sonar-scanner \
        -Dsonar.login=${{ secrets.SONAR_TOKEN }} \
        -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
        -Dsonar.projectKey=${{ secrets.PROJECT_KEY }} \
        -Dsonar.sources=.

hlebmymo avatar May 07 '22 09:05 hlebmymo

@KaioOCarvalho I think you need add step "subosito/flutter-action@v2" to make sure you installed flutter before sonarqube scanner run flutter analyze.

phuc-tranh-otsv avatar Jul 31 '22 12:07 phuc-tranh-otsv

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Oct 30 '22 03:10 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Nov 14 '22 03:11 github-actions[bot]