Code quality can be easily analyzed using SonarCloud, which is automatically configured by JHipster.
Using Sonar with JHipster
JHipster provides a specific Docker Compose configuration for Sonar (here is the JHipster Docker Compose documentation) that provides an out-of-the box Sonar instance. At the root of your project, please run:
docker-compose -f src/main/docker/sonar.yml up -d
If you use Maven, it has been automatically configured:
./mvnw -Pprod clean verify sonar:sonar -Dsonar.host.url=http://localhost:9001
If you need to re-run the Sonar phase, please be sure to specify at least the
initialize phase since Sonar properties are loaded from the sonar-project.properties file.
./mvnw initialize sonar:sonar -Dsonar.host.url=http://localhost:9001
If you use Gradle, it has also been automatically configured:
./gradlew -Pprod clean check sonarqube -Dsonar.host.url=http://localhost:9001
In every cases you can, now, run analysis with sonar-scanner if you already have installed it.
Once the analysis completes, it will be available on the Sonar dashboard, which by default is available on http://127.0.0.1:9001/.
Automatic analysis of the default generated project
The JHipster generator project publishes a sample project which is analyzed every time a new commit is merged in the “master” branch:
This allows the JHipster team to make sure that you will start developing your project on the cleanest code possible.
This analysis is provided for free by SonarCloud.