ava.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0


ERROR: Error during SonarScanner execution

java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0

at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)

at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)

at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)

at java.base/java.util.Objects.checkIndex(Objects.java:372)

at java.base/java.util.ArrayList.get(ArrayList.java:459)

at com.sonar.cpp.plugin.CompileCommandsReader.getCapture(CompileCommandsReader.java:116)

at com.sonar.cpp.plugin.CompileCommandsReader.readCaptures(CompileCommandsReader.java:59)

at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:870)

at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:400)

at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:212)

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.execute(ModuleSensorsExecutor.java:64)

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:399)

at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:395)

at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:364)

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:135)

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:112)

at org.sonarsource.scanner.cli.Main.execute(Main.java:75)

at org.sonarsource.scanner.cli.Main.main(Main.java:61)




Hi,

You’ve given no context for this. It’s not clear to me what you expect to happen.

Would you like to provide the full analysis log?

 
Ann

Hey,
I ran sonar scanner over my iOS project for cfamily.
I did generate a compilation database file and followed the instructions C/C++/Objective-C | SonarQube Docs

1 Like

Hey @ganncamp , providing the logs below

INFO: Project root configuration file: /Users/ShwetaMittal/iOS/sonar-project.properties
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.16.1 Homebrew (64-bit)
INFO: Mac OS X 12.4 aarch64
INFO: User cache: /Users/ShwetaMittal/.sonar/cache
INFO: Scanner configuration file: /opt/homebrew/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: /Users/ShwetaMittal/iOS/sonar-project.properties
INFO: Analyzing on SonarQube server 9.7.0.61563
INFO: Default locale: "en_IN", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=315ms
INFO: Server id: 147B411E-AYPvCRqqv2S6SoRrAUC4
INFO: User cache: /Users/ShwetaMittal/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=262ms
INFO: Load/download plugins (done) | time=353ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: Process project properties (done) | time=5ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=0ms
INFO: Project key: SA-8.1-CPP:pulsemobile
INFO: Base dir: /Users/ShwetaMittal/iOS
INFO: Working dir: /Users/ShwetaMittal/Desktop/iOS/.scannerwork
INFO: Load project settings for component key: 'SA-8.1-CPP:'
INFO: Load project settings for component key: 'SA-8.1-CPP:' (done) | time=323ms
INFO: Load project branches
INFO: Load project branches (done) | time=250ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=240ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=1ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=380ms
INFO: Load active rules
INFO: Load active rules (done) | time=10066ms
INFO: Load analysis cache
INFO: Load analysis cache | time=260ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=376ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 994 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: 265 files ignored because of scm ignore settings
INFO: Quality profile for c: Sonar way
INFO: Quality profile for cpp: Sonar way
INFO: Quality profile for js: Sonar way
INFO: Quality profile for json: Sonar way
INFO: Quality profile for objc: Sonar way
INFO: Quality profile for swift: Sonar way
INFO: ------------- Run sensors on module SA-8.1-CPP:pulsemobile
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=268ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=38ms
INFO: Sensor IaC Kubernetes Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Kubernetes Sensor [iac] (done) | time=10ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Sensor C# Analysis Log [csharp] (done) | time=13ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=3ms
INFO: Sensor Text Sensor [text]
INFO: 558 source files to be analyzed
INFO: 558/558 source files have been analyzed
INFO: Sensor Text Sensor [text] (done) | time=298ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=2ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=10ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: Sensor Swift Code Quality and Security [swift]
INFO: 82 source files to be analyzed
INFO: 82/82 source files have been analyzed
INFO: Sensor Swift Code Quality and Security [swift] (done) | time=2793ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
INFO: Sensor JavaScript analysis [javascript]
WARN: Node.js version 17 is not recommended, you might experience issues. Please use a recommended version of Node.js [16, 18]
INFO: 10 source files to be analyzed
INFO: 10/10 source files have been analyzed
INFO: Hit the cache for 0 out of 10
INFO: Miss the cache for 10 out of 10: ANALYSIS_MODE_INELIGIBLE [10/10]
INFO: Sensor JavaScript analysis [javascript] (done) | time=7469ms
INFO: Sensor TypeScript analysis [javascript]
INFO: No input files found for analysis
INFO: Hit the cache for 0 out of 0
INFO: Miss the cache for 0 out of 0
INFO: Sensor TypeScript analysis [javascript] (done) | time=0ms
INFO: Sensor CSS Rules [javascript]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [javascript] (done) | time=1ms
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
INFO: Sensor Serverless configuration file sensor [security]
INFO: 0 Serverless function entries were found in the project
INFO: 0 Serverless function handlers were kept as entrypoints
INFO: Sensor Serverless configuration file sensor [security] (done) | time=2ms
INFO: Sensor AWS SAM template file sensor [security]
INFO: Sensor AWS SAM template file sensor [security] (done) | time=1ms
INFO: Sensor AWS SAM Inline template file sensor [security]
INFO: Sensor AWS SAM Inline template file sensor [security] (done) | time=0ms
INFO: Sensor CFamily [cpp]
INFO: CFamily plugin version: 6.38.0.60268
INFO: Using compile commands: /Users/ShwetaMittal/iOS/compile_commands.json
INFO: Available processors: 10
INFO: Using 10 threads for analysis.
INFO: Found empty cache on server
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 36.426s
INFO: Final Memory: 44M/168M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:372)
	at java.base/java.util.ArrayList.get(ArrayList.java:459)
	at com.sonar.cpp.plugin.CompileCommandsReader.getCapture(CompileCommandsReader.java:116)
	at com.sonar.cpp.plugin.CompileCommandsReader.readCaptures(CompileCommandsReader.java:59)
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:870)
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:400)
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:212)
	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.execute(ModuleSensorsExecutor.java:64)
	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:399)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:395)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:364)
	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:135)
	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:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR: 

Hi,

I see you have some Swift and JS files in the project. Just to confirm, there are C++ files too, right? (I’m assuming so based on ‘CPP’ in the project key…)

 
Ann

yes, we have c++ as well as objective c code too

Hi,

Thanks for the confirmation. I’ve flagged this for more expert eyes.

 
Ann

1 Like

Hi @shweta.mittal19,

Can you share the /Users/ShwetaMittal/iOS/compile_commands.json
it seems that you have an invalid compilation database with an empty command.

Thanks,

@shweta.mittal19,

any update on this?

Thanks,