Introduce SonarCloud integration and resolve assorted violations (#575)

This commit is contained in:
Stephan Schroevers
2023-04-25 08:19:11 +02:00
committed by GitHub
parent 554a3e634c
commit e0c795d248
142 changed files with 450 additions and 211 deletions

View File

@@ -0,0 +1,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)