Code Quality with SonarQube and React Native

Adnan Sahinovic
Feb 23 · 2 min read

Learn how to integrate SonarQube in your React Native project.

SonarQube is a static analysis tool that provides us with five main reports:

  • Reliability
  • Security & Security Review
  • Maintainability
  • Test Coverage
  • Duplications

In other words, it analyses our code to gives a report of anything that’s wrong or could be wrong in the future. Recently, I couldn’t find any good documentation on SonarQube and React Native, so I documented the steps that I made to integrate these two.

Prerequisites:

  • Docker installed on your machine
  • Homebrew installed

Instructions

  1. brew install sonar-scanner (only first time)
  2. Download Docker and start it by running a command: docker run -d — name sonarqube -p 9000:9000 sonarqube
  3. Open http://localhost:9000/ and enter credentials: username: admin, password: admin
  4. Click + to create a new project and enter your Project Key and Display Name

5. Create sonar-project.properties in the project root, add sonar.projectName previously created and sonar.projectKey generated in the last step

6. Run sonar-scanner in terminal

Open http://localhost:9000/ and voila; analysis results are here.

Nerd For Tech

From Confusion to Clarification

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Adnan Sahinovic

Written by

Software Engineer. Sharing notes, thoughts & documenting my tech journey

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.