Rules Tagging system and Creating Quality Profile
Purpose
Rules Tagging system
Add one new tag to a list of rules from SONAR_RULES_REUSED.md (using SonarQube API).
Why? Because maybe some original SonarQube rules are already ready for being part of this plugin.
Creedengo Quality Profile
Add one new Profile by language inherited from SonarWay (using SonarQube API).
Why ?
-
We must create a custom Profile to use new eco-design rules from Creedengo plugins.
-
The new profile is inherited from SonarWay to keep natives SonarWay rules also. The script attaches the new rules with the new quality profile. The new profile becomes the default profile for the language.
Requirements
-
SonarQube installed
-
Got 'Admininister: Quality Profiles' global permission on your account
-
Setup
SonarQube
-
Add a new token in personal account settings to communicate with Sonar API ("user token" type)
-
Check
_config.shfile:Setting Variable Values Debug mode
DEBUG0to disable,1to enableSimulation mode
SIMULATION0to disable,1to enableSonar token
SONAR_TOKENthe token generated in the previous step
Sonar URL
SONAR_URLthe URL to your SonarQube instance (default:
http://localhost:9000)Name of the tag to add
TAG_ECODESIGNthe name of the new tag to add to a list of rules
File path to
SONAR_RULES_REUSED.mdFILEPATH_SONAR_RULES_REUSEDfilepath in the local folder, contains all rules
Name of the profile to add
PROFILE_ECODESIGNthe name of the new profile to add for each language
Language keys list
PROFILE_LANGUAGE_KEYSthe list of all languages to add the new Creedengo quality profile to (string format, separated with one comma)
Profiles set as default
IS_PROFILE_ECODESIGN_DEFAULT1for the newly created profiles to be set as default for each language,0to not change the default profiles
Local development environment
Different environments have been used:
-
bash 3.2 on macOS with extra
jqpackage (brew install jq) -
Ubuntu 20.04.4 LTS (bash 5.0.17(1)-release) with extra
jqpackage (sudo apt install jq)
Algorithm
Tagging scripts
-
get rules data (rules list from parsing
SONAR_RULES_REUSED.md) -
check if new tag to add (from config file) already exists on systags array or tags array
-
add new tag to all existing tags if necessary
-
check_tags.sh: read tags for all listed rules -
clean_tag.sh: delete specified tag from all listed rules -
install_tag.sh: add specified tag to all listed rules
How does it work?
-
change configuration in
_config.shfile: check requirements above -
launch
check_tags.shto control your rules and tags -
launch
install_tags.shto add custom tag to your rules -
launch
check_tags.shagain to control your rules and tags -
launch
install_profile.shto create profiles with the new rules from plugins