insideapp-oss / sonar-flutter

SonarQube plugin for Flutter / Dart
Other
449 stars 83 forks source link

Using `sonar.dart.analyzer.options.override=true` has no effect #180

Closed 73VW closed 1 year ago

73VW commented 1 year ago

Hello,

I have tried to use the analysis_options.yaml of my project using sonar.dart.analyzer.options.override=true.

In the output, it seems to backup the file and tries to restore it and crashes the same than in #179.

sonar-project.properties:

sonar.projectKey=XXX
sonar.qualitygate.wait=true
sonar.projectName=XXX
sonar.dart.analyzer.options.override=true

Output:

INFO: Backup of original analysis_options.yaml file to analysis_options.yaml.sonar
INFO: Running 'flutter [analyze, --no-fatal-warnings, --no-fatal-infos]'
INFO: Command 'flutter analyze --no-fatal-warnings --no-fatal-infos' finished (exit 1)
INFO: Restored original analysis_options.yaml file
INFO: Recording 5042 issues
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 48.804s
INFO: Final Memory: 32M/110M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalArgumentException: 105 is not a valid line for pointer. File analysis_options.yaml has 72 line(s)
        at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:353)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:289)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.selectLine(DefaultInputFile.java:312)
        at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerReportIssue.toNewIssueLocationFor(DartAnalyzerReportIssue.java:114)
        at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.lambda$recordIssues$0(DartAnalyzerSensor.java:100)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.recordIssues(DartAnalyzerSensor.java:89)
        at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.execute(DartAnalyzerSensor.java:80)
        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:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
        at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$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)
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
friedScotch commented 1 year ago

This is because of a false check in the Repo. If you want to use your custom analysis.yaml then use the following -Dsonar.dart.analyzer.options.override=false

I was thinking of creating a PR for this, maybe I should.