Leading in a volatile, uncertain, complex and ambiguous (VUCA) world is not a straightforward job with predefined success recipes.
Search by labels
Thursday, December 31, 2020
Wednesday, December 30, 2020
Code quality analysis with SonarQube setup locally in a Docker container
SonarQube is a leading tool for continuously inspecting the Code Quality and Security of codebases and guiding development teams during Code Reviews.
This tutorial will cover the steps for setting up a SonarQube instance in a Docker container on your local machine and performing an analysis of a test automation project developed in Java and built with Maven.
1. Install Docker and get the SonarQube image
Depending on the machine's OS, Docker is installed in different ways. In the case of this tutorial, the operating system was MacOS so Docker Desktop was initially installed.
Run in terminal: docker pull sonarqube
2. Start the SonarQube instance
Run in terminal: docker run -d --name SonarQube -p 9000:9000 sonarqube
Access the SonarQube instance at http://localhost:9000/ and login with username admin and password admin.
3. Create and configure a new SonarQube project
4. Run the SonarQube analysis of the Java project
Run in terminal in the project's folder (where the pom.xml file is located) the following command, shown also in the previous step:
mvn sonar:sonar \
-Dsonar.projectKey=automation-project \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=${token}5. Check the results of the analysis
The issues discovered come with detailed explanations and with the steps for fixing them.
As seen in this tutorial, it's free and simple to check the code quality of development projects regardless of their complexity, but the true power of SonarQube is unleashed when using the enterprise version and in a remote setup available for entire teams.


