In order to develop a Sonarqube Plugin in Open source for ecocode, two basics must have been mastered:
- How to develop a Sonarqube plugin
- Understand and work withe the Gitflow
https://docs.sonarqube.org/latest/extend/developing-plugin/
https://medium.com/android-news/gitflow-with-github-c675aa4f606a
https://github.com/cnumr/ecoCode/tree/main
https://collectif.greenit.fr/ecoconception-web/115-bonnes-pratiques-eco-conception_web.html
If you don't understand what a rule means, take a look at the link above. Mouse over in order to have more details.
https://olegoaer.perso.univ-pau.fr/android-energy-smells/
You will need to install Docker : https://docs.docker.com/get-docker/
Docker-compose 3.9 : https://docs.docker.com/compose/install/
Java >=11 for Sonarqube plugin Development : https://www.java.com/fr/download/manual.jsp
Maven 3 for Sonarqube plugin Development : https://maven.apache.org/download.cgi
Additionnaly, install Git : https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
Clone the project with :
git clone https://github.com/cnumr/ecoCode.git
You will find all the steps to start a Sonarqube dev Environment here : https://github.com/cnumr/ecoCode/blob/main/src/INSTALL.md
Chose a rule in a specific language in the "To do" column : https://github.com/cnumr/ecoCode/projects/1 and move it to the "In progress"
Each rule needs to have scripts in a specific language (i.e. Python, Rust, JS, PHP and JAVA) in order to test directly inside Sonarqube that the rule has been implemented.
To validate that the rule has been implemented, you need to execute a scan on those scripts. You will need sonar scanner: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/
Create a new branch following this pattern : <rule_id>- Example :
git checkout -b 47-JS
Commit your code :
git add .
git commit -m "your comments"
Push your branch :
git push origin <rule_id>-<language>
You may have to log with your account : https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
Once your code is pushed and tested, open a PR between your branch and "main" : https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
Ask to people to review your PR. Once two people, at least, have reviewed, you can validate your PR If you want to be reviewed, review others... It's a win/win situation
Validate your PR or ask to someone who have the permissions to validate your PR
Once your PR is validated, your rule integrates ecoCode. In https://github.com/cnumr/ecoCode/projects/1, move it from the "In Progress" column to the "Done" column. Well done.