[HOW-TO] SonarQube - code quality

URL : https://sonarqube.n10.xyz/projects

connect with your account gitlab

Now you can navigate in different project an see different informations:

Or you can create a new project to analyse the code

HOW TO add a new repositories

Create a project from gitlab

search your repositories ans click on set up :

Select wih gitlab CI

and follow the instruction:

Go on your repositoriy gitlab.n10.xyz

and add 2 variables :

When you generate a token : Select No Expiration

Now you must have 2 variables :

Create a .gitlab-ci.yml to automatize the synchronisation when you push your code with this pipeline code

sonarqube-check:
  image: 
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script: 
    - sonar-scanner
  allow_failure: true

you must have 2 files modify :

finish setup on sonarqube.n10.xyz

push your commit now & Go on CI/CD Pipeline in the menu

The pipeline will be play each push

Go on https://sonarqube.n10.xyz/projects

Pipeline finish you must this the result

Enjoy you can fix everything now !

115 ФЗ