aboutsummaryrefslogtreecommitdiff
path: root/nvim/scripts/sonarqube.sh
blob: 15c042e69521aad11f32df8cf945ab2961bdef04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

set -eu

SONAR_CONFIGURATION_FILE="/opt/homebrew/etc/sonar-scanner.properties"
PROJECT_FILE=$(find . -maxdepth 1 -name "sonar-project*.properties" | head -n 1)

if [ -z "$PROJECT_FILE" ]; then
  echo "Keine sonar-project*.properties Datei gefunden!" >&2
  exit 1
fi

SONAR_TOKEN=$(awk -F= '/^sonar.token=/ {print $2}' "$SONAR_CONFIGURATION_FILE")
SONAR_HOST_URL=$(awk -F= '/^sonar.host.url=/ {print $2}' "$SONAR_CONFIGURATION_FILE")
PROJECT_KEY=$(awk -F= '/^sonar.projectKey=/ {print $2}' "$PROJECT_FILE")

curl -s \
  -u "$SONAR_TOKEN:" \
  "$SONAR_HOST_URL/api/issues/search?componentKeys=$PROJECT_KEY&statuses=OPEN&ps=500" |
  jq -r '.issues[] | "\(.component | sub("^[^:]+:"; "")):\(.line // 1): [\(.severity)] \(.message | gsub("\n"; " ")) (\(.author))"'