# SonarQube Quick Start **5-minute setup guide for SonarQube code quality analysis.** --- ## โœ… What's Already Done - โœ… `sonar-project.properties` - Project configuration - โœ… CI pipeline job - `sonar-analysis` added - โœ… Coverage report generation - Integrated with pytest --- ## ๐Ÿš€ Quick Setup (3 Steps) ### Step 1: Create Project in SonarQube 1. Login to SonarQube: `http://your-server:9000` 2. **Projects** โ†’ **Create Project** 3. **Project Key:** `pote` 4. **Display Name:** `POTE` 5. Click **Set Up** ### Step 2: Generate Token 1. **My Account** โ†’ **Security** โ†’ **Generate Token** 2. **Name:** `POTE CI/CD` 3. **Type:** User Token 4. Click **Generate** 5. **โš ๏ธ COPY THE TOKEN** (you won't see it again!) ### Step 3: Add Secrets to Gitea 1. Go to: `https://git.levkin.ca/ilia/POTE/settings/secrets/actions` 2. Add secret: `SONAR_HOST_URL` = `http://your-server:9000` 3. Add secret: `SONAR_TOKEN` = (paste token from Step 2) --- ## ๐Ÿงช Test It ```bash # Push to dev branch git push origin dev # Check CI results # https://git.levkin.ca/ilia/POTE/actions # View SonarQube results # http://your-server:9000/dashboard?id=pote ``` --- ## ๐Ÿ“‹ Configuration ### Project Key - **Key:** `pote` (in `sonar-project.properties`) - **Name:** `POTE` - **Version:** `0.1.0` ### Source Code - **Sources:** `src/` - **Tests:** `tests/` - **Coverage:** `coverage.xml` (auto-generated) ### Exclusions - `__pycache__/`, `*.pyc` - `venv/`, `tests/` - `alembic/versions/` --- ## ๐Ÿ”ง Customize Edit `sonar-project.properties`: ```properties sonar.projectKey=pote sonar.projectName=POTE sonar.sources=src sonar.tests=tests ``` --- ## ๐Ÿ“Š View Results **SonarQube Dashboard:** ``` http://your-server:9000/dashboard?id=pote ``` **Metrics:** - Code Coverage - Bugs & Vulnerabilities - Code Smells - Technical Debt - Quality Gate Status --- ## ๐Ÿ› Troubleshooting ### "Project does not exist" โ†’ Create project manually in SonarQube UI ### "Authentication failed" โ†’ Check `SONAR_TOKEN` secret is correct ### "Connection refused" โ†’ Verify `SONAR_HOST_URL` and server accessibility ### "Coverage not found" โ†’ Ensure pytest runs before SonarScanner (already configured) --- ## ๐Ÿ“– Full Documentation See: `docs/17_sonarqube_setup.md` for complete guide. --- **Setup Time:** ~5 minutes **CI Integration:** โœ… Already done **Manual Steps:** 3 (create project, generate token, add secrets)