Closed paranjay-patel closed 6 months ago
Hi, I've run in the exact same issue when running sonar-scanner from a docker container.
I had to run flutter pub get
before running sonar-scanner
, all inside the container where I have installed both flutter (+dart) and sonar scanner.
EDIT: Strangely enough, I'm back on the problem even after flutter pub get. I'll keep you updated if I fix the issue
EDIT 2: Found out.
flutter pub get
before sonar-scanner
sonar-project.properties
file contains the following:sonar.projectKey=your-project-key
sonar.projectName=your-project-name
sonar.projectVersion=0.0.1
sonar.sourceEncoding=UTF-8
sonar.dart.analyzer.options.override=false
sonar.sources=lib,pubspec.yaml
sonar.tests=test
I am also facing same issue
07:44:08.826 DEBUG: Analyzer configured for mode: FLUTTER
07:44:08.826 DEBUG: Analyzer configured for output mode: MACHINE
07:44:08.826 INFO: Using existing analysis_options.yaml since override is disabled
07:44:08.826 INFO: Running 'flutter [analyze, --no-fatal-warnings, --no-fatal-infos]'
07:44:11.544 INFO: Command 'flutter analyze --no-fatal-warnings --no-fatal-infos' finished (exit 1)
07:44:11.556 INFO: ------------------------------------------------------------------------
07:44:11.556 INFO: EXECUTION FAILURE
07:44:11.556 INFO: ------------------------------------------------------------------------
07:44:11.557 INFO: Total time: 9.323s
07:44:11.590 INFO: Final Memory: 29M/114M
07:44:11.590 INFO: ------------------------------------------------------------------------
07:44:11.590 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Error while running 'flutter analyze --no-fatal-warnings --no-fatal-infos' (exit 1): 314 issues found. (ran in 1.8s)
at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.executable.AnalyzerExecutable.maybeThrowException(AnalyzerExecutable.java:103)
at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.executable.AnalyzerExecutable.analyze(AnalyzerExecutable.java:91)
at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.execute(DartAnalyzerSensor.java:67)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:201)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:180)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:398)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:394)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:363)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:201)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:180)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:139)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:201)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:180)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:71)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:65)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
sonar.dart.analyzer.options.override=false This will help get past the "flutter analyze" step but now I am encountering another error further down. This does not explain why the sonar scanner gets the IllegalStateException.
I also got the same issue, no matter if I change the flag to TRUE or FALSE. This is my properties file:
# Project identification
sonar.projectKey=MyProj
sonar.projectName=MyProj
sonar.projectVersion=1.0
sonar.token=MyToken
sonar.host.url=http://localhost:9000
sonar.sources=.
#lib,pubspec.yaml
#sonar.tests=test
sonar.lang.patterns.dart=**/*.dart
# Encoding of the source code. Default is default system encoding.
sonar.sourceEncoding=UTF-8
sonar.exclusions=test/**/*_test.mocks.dart,lib/**/*.g.dart
sonar.java.binaries= **/*.java
sonar.dart.analyzer.options.override=false
I'm using the SonarQube Common Edition 10.4.
somethings that I noticed -- most of my problems went away when I switched the branch to the default branch of GIT.
And I find that the sonarqube does not do much beyond what is already done by "flutter anallyze". Thus, I am not putting much emphasis to get this working further. The sonar-scanner can run to completion and send the reports back to sonarqube. But the results are not that impressive compared to what is already identified by the flutter analyze.
I can share my sonar-project.properties if you DM me
I repeated all the steps today, the only change was the use of the sonar-flutter-plugin-0.5.1-SNAPSHOT.jar instead of the previous sonar-flutter-plugin-0.5.0.jar and it seems to work now. I don't know if this is because I closed and opened the server to do this and maybe something cleaned up, anyway as far as I read the stats, it seems correctly analyzed now.
Same experience with @AntonioZan.
My pipeline succeeded without any additional changes in sonar.properties file
it would be useful to generate new release with this change @zippy1978
Hi, I've run in the exact same issue when running sonar-scanner from a docker container.
I had to run
flutter pub get
before runningsonar-scanner
, all inside the container where I have installed both flutter (+dart) and sonar scanner.EDIT: Strangely enough, I'm back on the problem even after flutter pub get. I'll keep you updated if I fix the issue
EDIT 2: Found out.
- run
flutter pub get
beforesonar-scanner
- make sure your
sonar-project.properties
file contains the following:sonar.projectKey=your-project-key sonar.projectName=your-project-name sonar.projectVersion=0.0.1 sonar.sourceEncoding=UTF-8 sonar.dart.analyzer.options.override=false sonar.sources=lib,pubspec.yaml sonar.tests=test
How to run flutter pub get inside the container?
Mshimaz --depending on how you run sonarqube, you can add that flutter pub get into your docker script. I usually run my scan from inside an azure devops pipeline (another form of CICD build system from azure) and use a flutter plugin from azure. https://marketplace.visualstudio.com/items?itemName=Hey24sheep.flutter
Mshimaz --depending on how you run sonarqube, you can add that flutter pub get into your docker script. I usually run my scan from inside an azure devops pipeline (another form of CICD build system from azure) and use a flutter plugin from azure. https://marketplace.visualstudio.com/items?itemName=Hey24sheep.flutter
I tried to run the command in the script, but its saying the flutter command is missing. Should I need to install here. If so how can I do that?. Also is there something else I can do to solve the above mentioned error.
Fixed in new release: https://github.com/insideapp-oss/sonar-flutter/releases/tag/0.5.1
sonar-scanner command giving below error while scanning flutter application. why its giving this error, what should be the possible solution for the issue. i am using gitlab pipeline.
gitlab-ci
sonar-projects.properties files