aboutsummaryrefslogtreecommitdiff
path: root/nvim/scripts/sonarqube.sh
blob: ef1be89422df21b6363a2bd8a70a824cac249de9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh

set -eu

SONAR_TOKEN=$(awk -F= '/^sonar.token=/ {print $2}' /opt/homebrew/etc/sonar-scanner.properties)
SONAR_HOST_URL=$(awk -F= '/^sonar.host.url=/ {print $2}' /opt/homebrew/etc/sonar-scanner.properties)
PROJECT_KEY=$(awk -F= '/^sonar.projectKey=/ {print $2}' ./sonar-project.properties)

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