Sonar Windows tutorial can test projects directly

Recently in the study of Sonar, because of their own research, Windows tutorial and too little, suddenly shed tears. This is a detailed super detailed tutorial

SonarQube is an open platform for code quality management that can quickly locate potential or obvious errors in your code. Here’s how to install and configure SonarQube and use http://www.sonar.org.cn/

The installation package

Link: https://pan.baidu.com/s/1IsAXYRTVe0BsCUfGSLAO0Q extraction code: bl8o copy after this paragraph open baidu cloud mobile phone App, operation more convenientCopy the code

First of all, on a very clean computer, you need to prepare these things

1, the Java SDk

In my Baidu cloud disk is Java 8, must bear in mind, some Java version is not compatible with high when you install Java will start to match the Java environment win7 environment variable configuration as follows

Key :JAVA_HOME value:D: program Files \ Java \jdk1.8.0_121 // This path is your Java installation pathCopy the code
key:CLASSPATH value: .; %JAVA_HOME%\lib\dt.jar; %JAVA_HOME%\lib\tools.jar // before. Do add oh, I didn't write it wrong.Copy the code

Add to your system variable path

; %SONAR_SCANNER_HOME%\bin; %JAVA_HOME%\bin; %JAVA_HOME%\jre\binCopy the code

To test whether the JDK is installed, open the CMD window and run the Java -version, Java, and javac commands. If all the commands are successful, the installation is successful

2. Install Sonarqube

Baidu cloud link has sonarqube installation package, open the installation package bin corresponding system startsonar.bat

Can run up open http://localhost:9000/



Sonar -scanner- 4.5.0.2216-Windows

Since maruko uses a method without a mysql database, this will be installed to run the project

Procedure 1 Decompress the downloaded package to a directory. 2 Open the /conf/ Sonar – Scanner. Properties file in the root directory of Sonar Scanner and configure the following:

# -- -- -- -- -- the Default SonarQube sonar. The server host. The url = http://192.168.22.210:9000 # -- -- -- -- -- the Default source code encoding sonar.sourceEncoding=UTF-8Copy the code

Sonar. Host. Url is your local address, you need to modify

  1. Create the system variable SONAR_SCANNER_HOME=Sonar Scanner root directory, modify the system variable path, add %SONAR_SCANNER_HOME%\bin,

    Open CMD panel, input sonar-scanner -version, the picture below appears, it indicates that the environment variable is set successfully

Go into your own projects



The new file

sonar-project.properties

The following

# must be unique in a given SonarQube instance # sonar.projectKey=my:project # --- optional properties --- # defaults to ProjectName =My project # defaults to 'not provided' #sonar. ProjectVersion =1.0 # Path is relative to the sonar-project.properties file. Defaults to . #sonar.sources=. # Encoding of the source code. Default is default System encoding #sonar. SourceEncoding =UTF-8 sonar sonar.language=js sonar.sources=./srcCopy the code

CMD to enter the project root directory, then enter “sonar-scanner” command, enter the static code analysis.



Open up here and you’ll see it

4. There are actually two schemes for the Chinese package, one is the latest 1

Log in to the system, go to the page of Administration > Marketplace, enter Chinese in the search box, a Chinese Pack will appear, click the install button on the right to install. When the installation is successful, you will be prompted to restart the SonarQube server. Just wait until the prompt box disappears and the page will already display Chinese.

2

But meatball tried this method, saying that the version is relatively low, because every time the Chinese package is updated is the latest version, meatball there are also corresponding Chinese package, if your version of sonar is not the same as mine, you can github.com/SonarQubeCo… Download the corresponding Chinese package here, put the plugins into \extensions\plugins and restart sonar.

Sonar:

1. Close the Sonarqube.bat window first

2. Ctrl+Shift+Esc to bring up Windows Explorer

3. Close all the java.exe processes

4, then re-enter.\sonarqube-4.5.7\bin\windows-x86-32 and run the StartSonar

If you have a Mysql can refer to www.sonar.org.cn/install/189…