Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Analysing a React Native Project Using SonarQube?

enter image description here

I have installed sonarqube inside a virtual machine in my system.And is able to access it from anywhere inside my local network.

I am trying to analyse the java-script files of my react-native project which is inside the app folder as shown in the above screenshot.

so i set up a sonar-project.properties file inside the base directory of react-native project(as shown in the above screenshot) according to the sonarqube official doc in the below link

https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner

and from the base directory i am trying push the file using sonar-scanner command (i am doing this from outside the virtual machine from my system os).

and it shows sonar-scanner command not found(as in the blow screenshot). enter image description here

How does this sonar-scanner command work ?,when accessing sonarserver from outside the virtualmachine do need something extra in my system os other than sonar-project.properties file in my projects root directory ? ,do i need to install something in my system os to use the command sonar-scanner.

And what does the below property do

// To import the LCOV report

sonar.javascript.lcov.reportPath=report/lcov.dat

And how do i properly configure it for my project ?

like image 832
Amal p Avatar asked May 23 '17 05:05

Amal p


People also ask

Does SonarQube support react native?

SonarQube is an open-source platform developed by SonarSource for continuous inspection of code quality. SonarQube is a tool to perform static code analysis which provides a detailed report for, bugs.

Does SonarQube work with react?

SonarQube is a tool that helps you catch bugs and vulnerabilities in your app. Working together with ESLint and Unit tests, it provides a great code quality scan. On this tutorial, I will show you how to set up SonarQube and run locally over a React TypeScript project.


1 Answers

As described on https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner, you have to follow these steps:

  1. Download the executable for your platform
  2. Extract it somewhere
  3. Add the sonar-scanner executable (that was expanded in <install_directory>/bin folder

Alternatively, because you are developing a JS project, you can also use the SonarQube Scanner for JS thanks to which you won't have to bother with the standard SonarQube Scanner and its properties file. For example, you can write the following script and add it to your package.json file:

let sonarqubeScanner = require('sonarqube-scanner');

sonarqubeScanner({
  serverUrl : "https://localhost:9000",
  token : "019d1e2e04eefdcd0caee1468f39a45e69d33d3f",
  options : {}
}, callback);
like image 174
Fabrice - SonarSource Team Avatar answered Oct 04 '22 22:10

Fabrice - SonarSource Team