Forrest logo
back to the sonar-scanner tool

sonar-scanner:tldr:91cf0

sonar-scanner: Scan a project with configuration file in your project's root directory named `sonar-project.properties`.
$ sonar-scanner
try on your machine

The command "sonar-scanner" is used to run the SonarScanner tool, which is a command-line tool for analyzing code quality. SonarScanner is a part of the SonarQube platform, which is an open-source tool used for continuous inspection of code quality.

When you run the "sonar-scanner" command, it initiates the scanner to analyze your codebase and gather various code metrics and quality-related information. It typically performs the following steps:

  1. Reads the configuration: The SonarScanner reads a configuration file (typically named "sonar-project.properties") present in your project directory. This file contains various settings like the project key, project name, source directories, exclusions, SonarQube server details, and more.

  2. Compiles the code (if needed): If your project requires compilation (e.g., for Java projects), the SonarScanner might invoke the appropriate compiler to compile your code.

  3. Analyzes the code: The SonarScanner performs a static code analysis by running various analyzers, plugins, and rules provided by SonarQube. It scans your source code, identifies issues, and measures code metrics such as code coverage, code duplication, complexity, maintainability, security vulnerabilities, and other quality-related aspects.

  4. Sends the analysis report to SonarQube server: After completing the code analysis, the SonarScanner sends the generated analysis report to the SonarQube server, either locally or remotely. The server processes this report and stores the results, which can be accessed through the SonarQube user interface.

Overall, the "sonar-scanner" command allows developers to incorporate code quality analysis as a part of their development workflow. It helps improve code maintainability, identify bugs, security vulnerabilities, and follow best practices for developing high-quality software.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the sonar-scanner tool