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

Analysis fails if any pubspec.yaml file does not have a dependencies key #205

Open
LPLabrys99 opened this issue Jan 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@LPLabrys99
Copy link

LPLabrys99 commented Jan 5, 2024

Hi there,

I'm trying the sonar-flutter plugin on a project. There is a top-level pubspec.yaml file which is just used for tracking the target dart version.

When the sonar scanner runs it causes a java exception:

java.lang.NullPointerException: Cannot invoke "java.util.Map.containsKey(Object)" because the return value of "java.util.Map.get(Object)" is null
INFO: ------------------------------------------------------------------------
	at fr.insideapp.sonarqube.dart.lang.PubSpecParser.parse(PubSpecParser.java:60)
	at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.execute(DartAnalyzerSensor.java:66)
	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: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:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:139)
	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: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.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	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)

I had a look through the source code and I believe it's tripped up because one of the pubspec.yaml files does not have a dependencies entry, which this line seems to assume will be present.

https://github.com/insideapp-oss/sonar-flutter/blob/master/dart-lang/src/main/java/fr/insideapp/sonarqube/dart/lang/PubSpecParser.java#L60C23-L60C30

This is what the pubspec.yaml file looks like:

name: project_workspace

environment:
  sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
  melos: ^3.2.0

Thanks

Edit:
I found a temporary workaround, add this to the pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
Copy link

github-actions bot commented Apr 5, 2024

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

@github-actions github-actions bot added the stale label Apr 5, 2024
@santitigaga
Copy link

I think it is more inconvenient to check the pubspec.yaml in version 0.5, in version 0.4 it was not taken into account to analyze the project.

@github-actions github-actions bot removed the stale label Apr 17, 2024
@zippy1978 zippy1978 added the bug Something isn't working label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants