SonarQube is an open-source platform developed by SonarSource, which checks the quality of your code by running continuous checks for bug detection, code smells and security vulnerabilities. It supports over 20 programming languages.
We take the steps below, to run a health check on a Flask project:
- Create and switch to a virtual environment
python3 -m venv venv source venv/bin/activate
- Install requirements
pip3 install -r requirements.txt
- Run the project
- Install SonarQube using Docker
docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest
- Run SonarQube locally
Default username and password is admin for both fields.
If asked to update password, kindly do so
We install SonarQube scanner following the prompts in this article.
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-22.214.171.1243-linux.zip unzip sonar-scanner-cli-126.96.36.1993-linux.zip sudo mv sonar-scanner-188.8.131.523-linux /opt/sonar-scanner
- Edit the
- Create a file to automate the required environment variables configuration
sudo nano /etc/profile.d/sonar-scanner.sh
#/bin/bash export PATH="$PATH:/opt/sonar-scanner/bin"
- Add the sonar-scanner commands, to PATH variables
- Verify that the PATH variable was changed as expected
env | grep PATH
- Verify SonarQube scanner was installed
- Next, run the command as marked in red ink in the picture below.
The command should be ran in the directory where you installed SonarQube
SonarQube web page
Checkout my GitHub Repo to view my files.