As mentioned above, sonarqube can be used to analyze code quality in five ways. The first method is omnipotent.
Download the source code to the server where sonarqube is located, for example, the following directory structure:
However, under this root directory, create a sonar-project.properties file, as shown in the configuration.
# Required metadatasonar.projectKey=my:testtoolssonar.projectName=testoolssonar.projectVersion=1.0 # Path to the parent source code directory.# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.# Since SonarQube 4.2, this property is optional if sonar.modules is set. # If not set, SonarQube starts looking for source code from the directory containing # the sonar-project.properties file.sonar.sources=src # Encoding of the source codesonar.sourceEncoding=UTF-8sonar.language=py # Additional parameterssonar.my.property=value
1. The project Key and project name must be unique. Do not overwrite a project with the same name?
2. Sonar. Sources = SRC indicates that the source code is in the src directory.
3. Sonar. Language = py: specifies that the source code is Python. If this parameter is not specified, sonarrunner can analyze the language automatically, that is, the speed is slow.
After the analysis, you can see the report through the page, http: // 192.168.22.99: 9001/sonarqube, as shown in.
Carefully analyzing the description of each rule is helpful for developers to improve code quality. At the same time, quality control is also very helpful when QA personnel participate in code review.
Use sonarqube to check and Measure code quality (2) -- use sonarqube to analyze code Quality