Vighnesh Pai
Vighnesh Pai

Reputation: 1843

On running sonar analysis on react-native project getting error related to sonar.java.binaries property

I have a react-native project written in JavaScript for which I'm trying to run the sonar-analysis.

I have a sonar server set-up for this and system where I'm trying to run the analysis has Sonar-scanner, npm and all other project dependencies installed.

However, When I run the sonar analysis on the react-native project I'm getting following error:

ERROR: Error during SonarQube Scanner execution
org.sonar.squidbridge.api.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
    at org.sonar.java.JavaClasspath.init(JavaClasspath.java:59)
    at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:281)
    at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:141)
    at org.sonar.java.JavaSquid.<init>(JavaSquid.java:83)
    at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:83)
    at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
    at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
    at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:111)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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:233)
    at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
    at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Upvotes: 2

Views: 2412

Answers (2)

Nirojan Selvanathan
Nirojan Selvanathan

Reputation: 11164

Had the same issue, and was wondering where did java files came in to a node project. Then by doing a file search I found several java classes in the node_modules folder. Was able to move forward by excluding them in the sonar properties file.

sonar.exclusions=test/**, node_modules/**

Upvotes: 5

G. Ann - SonarSource Team
G. Ann - SonarSource Team

Reputation: 22804

The error message is actually pretty clear:

Please provide compiled classes of your project with sonar.java.binaries property

Your project includes Java files, which cannot be analyzed without also providing their compiled .class files. You must either first compile (and feed the class file location into analysis) or exclude the .java files from analysis.

Upvotes: 0

Related Questions