- Docker
- Docker-compose 3.9
Here is a preview of project tree :
Ecocode # Root directory of "native" linter
|
+--android-plugin # Android
|
+--java-plugin # JAVA
|
+--php-plugin # PHP
|
+--python-plugin # Python
|
\--docker-compose.yml # Docker compose file installing available analyzer // TODO
You will find more information about the plugins’ architecture in their folders
- Java >= 11
- Mvn 3
The Android plugin uses CodeNarc to scan the gradle files of Android projects. To have more information about CodeNarc: CodeNarc.
CodeNarc must be built separately. Please see the following steps:
Build CodeNarc (Gradle 6.9.2, Java 11), then add this custom-built CodeNarc to Maven dependencies:
./prepare-codenarc
You can build the project code by running the following command in the src
directory.
Maven will download the required dependencies.
./build.sh
# execute `mvn clean install`
Each plugin is generated in its own <plugin>/target
directory, but they are also copied to the lib
directory.
You must have built the plugins (see the steps above).
Run the SonarQube + PostgreSQL stack:
./init_reinit.sh
# execute `docker-compose up --build -d`
Check if the containers are up:
docker ps
You should see two lines (one for sonarqube and one for postgres). If there is only postgres, check the logs:
docker ps -a
docker logs src_sonar_1
If you have this error on run:
web_1 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
you can allocate more virtual memory:
sudo sysctl -w vm.max_map_count=262144
For Windows:
wsl -d docker-desktop
sysctl -w vm.max_map_count=262144
Go to http://localhost:9000 and use these credentials:
login: admin
password: admin
When you are connected, generate a new token:
My Account -> Security -> Generate Tokens
Start again your services using the token:
TOKEN=MY_TOKEN docker-compose up --build -d
Install dependencies from the root directory:
mvn clean install
.jar files (one per plugin) will be moved in lib
repository after build.
Once you did the installation a first time (and then you did custom configuration like quality gates, quality profiles, ...), if you only want to start (or stop properly) existing services :
./start.sh
# execute `docker-compose start`
./stop.sh
# execute `docker-compose stop`
- Java how-to : https://github.com/SonarSource/sonar-java/blob/master/docs/CUSTOM_RULES_101.md
- Python how-to : https://github.com/SonarSource/sonar-custom-rules-examples/tree/master/python-custom-rules
- PHP how-to : https://github.com/SonarSource/sonar-custom-rules-examples/tree/master/php-custom-rules