forked from PicnicSupermarket/error-prone-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list-sonarcloud-profile-modifications.sh
executable file
·44 lines (36 loc) · 1.18 KB
/
list-sonarcloud-profile-modifications.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
# Compares the `Picnic` SonarCloud quality profile for Java against the default
# `Sonar way` profile. While the web UI also provides such functionality, this
# script also compares the configuration parameters of each rule.
#
# This script uses `faq`, see https://github.com/jzelinskie/faq.
set -e -u -o pipefail
if [ -z "${SONAR_TOKEN}" ]; then
echo 'Environment variable `SONAR_TOKEN` is not set.'
exit 1
fi
export_profile() {
local profile="${1}"
curl --fail --silent --user "${SONAR_TOKEN}:" \
"https://sonarcloud.io/api/qualityprofiles/export?qualityProfile=${profile}&language=java&organization=picnic-technologies"
}
tabulate() {
faq --raw-output '
def enumerate_params:
if .parameters == "" then
[]
elif (.parameters.parameter | type) == "object" then
.parameters.parameter | [.key, .value]
else
.parameters.parameter[] | [.key, .value]
end;
.profile.rules.rule
| map([.repositoryKey, .key, .priority] + enumerate_params)
| sort
| .[]
| @tsv
' --output-format json
}
vimdiff \
<(export_profile 'Sonar%20way' | tabulate) \
<(export_profile 'Picnic%20Public' | tabulate)