Add SonarQube workflow and test file
Some checks failed
SonarQube Analysis / sonarqube (push) Failing after 46s
Some checks failed
SonarQube Analysis / sonarqube (push) Failing after 46s
This commit is contained in:
20
.gitea/workflows/sonarqube.yaml
Normal file
20
.gitea/workflows/sonarqube.yaml
Normal file
@@ -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 }}
|
||||||
15
app.js
Normal file
15
app.js
Normal file
@@ -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"));
|
||||||
4
sonar-project.properties
Normal file
4
sonar-project.properties
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
sonar.projectKey=test-sonarqube
|
||||||
|
sonar.projectName=Test SonarQube
|
||||||
|
sonar.sources=.
|
||||||
|
sonar.exclusions=**/.gitea/**
|
||||||
Reference in New Issue
Block a user