From d91c8004609de9de058d90c248eeceb388b10131 Mon Sep 17 00:00:00 2001 From: joker Date: Sat, 3 Jan 2026 20:16:56 +0000 Subject: [PATCH] Add SonarQube workflow and test file --- .gitea/workflows/sonarqube.yaml | 20 ++++++++++++++++++++ app.js | 15 +++++++++++++++ sonar-project.properties | 4 ++++ 3 files changed, 39 insertions(+) create mode 100644 .gitea/workflows/sonarqube.yaml create mode 100644 app.js create mode 100644 sonar-project.properties diff --git a/.gitea/workflows/sonarqube.yaml b/.gitea/workflows/sonarqube.yaml new file mode 100644 index 0000000..27de04f --- /dev/null +++ b/.gitea/workflows/sonarqube.yaml @@ -0,0 +1,20 @@ +name: SonarQube Analysis + +on: + push: + branches: [main, master, develop] + pull_request: + +jobs: + sonarqube: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} diff --git a/app.js b/app.js new file mode 100644 index 0000000..42d7ef3 --- /dev/null +++ b/app.js @@ -0,0 +1,15 @@ +// Test file for SonarQube analysis +function greet(name) { + if (name == null) { // Bug: should use === for strict comparison + return "Hello, World!"; + } + return "Hello, " + name + "!"; +} + +// Code smell: unused variable +var unusedVar = 42; + +// Security hotspot: hardcoded password +const password = "admin123"; + +console.log(greet("SonarQube")); diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..d323503 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,4 @@ +sonar.projectKey=test-sonarqube +sonar.projectName=Test SonarQube +sonar.sources=. +sonar.exclusions=**/.gitea/**