Before getting into this tutorial please read the information about the Sonarlint by clicking on this link.
Sonarlint helps the developer analyzes the code quality on the fly and displays the scan results. Now the Question is, would it be possible to push these results to SonarQube.
What is SonarQube??
SonarQube provides the capability of displaying the results in a Dashboard. And it also helps to configure the Quality Gate to improve the Code Quality. If we want to publish the results from Sonarlint to SonarQube the code does not require any compilation. Once the code scans are done we can push the results directly into SonarQube.
Bind the Sonarlint to SonarQube:
Right click on the project in Eclipse Select Sonarlint->Bind to SonarQube to SonarCloud option as mentioned below:
Select the connection type as SonarCloud and click on Next button.
Provide the Token generated from SonarCloud Server in the mentioned dialog box.
Access the SonarCloud server URL https://sonarcloud.io/projects as mentioned below.
Click on Analyze new project button and
Provide all the required information and click onSet Up button.
Click on the Generate button for generating new token.
Run the analysis on your project.
Execute the Command from the Command line to push results of Sonarlint to the SonarQube Cloud.
mvn sonar:sonar \
-Dsonar.projectKey=SonarlintScanResults \
-Dsonar.organization=totalqa \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=5a24ca7f4b56ccabd93da62f36915f08f8517482
Conclusion
Results generated from Sonarlint are pushed into SonarQube Server Successfully.