Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Construction method of SonarQube7.4 and sonar-Scanner-3.2.0 Environment

Shulou Source: shulou.com Published: 2022-06-02 08:35:16 09月30日 Update

This article mainly explains the "SonarQube7.4 and sonar-Scanner-3.2.0 environment building methods", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "SonarQube7.4 and sonar-Scanner-3.2.0 environment building methods" bar!

SonarQube is a static code checking tool, which uses BPX S architecture to help check code defects, improve code quality and improve development speed. Through plug-ins, it can support code quality management and testing in more than 20 programming languages, such as Java, C, C++, JavaScripe and so on.

Through the client plug-in to analyze the source code, the sonar client can use IDE plug-in, Sonar-Scanner plug-in, Ant plug-in and Maven plug-in, and analyze and scan the project source code through various analysis mechanisms, upload the scanned results to the sonar database, and manage the analysis results through the sonar web interface.

Code quality can be detected from seven dimensions:

(1) complexity distribution (complexity): code complexity is too high to understand.

(2) duplicate code (duplications): the program contains a large number of copied and pasted code, resulting in bloated code. Sonar can show serious repetition in the source code.

(3) Unit Test Statistics (unit tests): statistics and display unit test coverage. Developers or tests can clearly test code coverage.

(4) Code rule check (coding rules): check whether the code conforms to the specification through Findbugs,PMD,CheckStyle, etc.

(5) comments: if the code comments are too little, especially after the personnel change, it will be difficult for others to take over; if too much, it is not good for reading

(6) potential Bug (potential bugs): detect potential bug by Findbugs,PMD,CheckStyle, etc.

(7) structure and design (architecture & Design): find out loops, show package-to-package, class-to-class dependencies, check coupling between programs.

SonarQube build steps to install jdk1.8, note: different versions of SonarQube have different requirements for jdk. Install MySQL 5.7.20 environment and create an instance. Note: SonarQube supports downloading SonarQube7.4 and sonar-scanner-3.2.0 configuration SonarQube with mysql database above version 5.6.

I built the machine: windows server2008 R2 64-bit

Configuration file: sonarqube-7.4\ conf\ sonar.properties

Add the following database configuration:

Sonar.jdbc.url=jdbc:mysql:///sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

Sonar.jdbc.username=root

Sonar.jdbc.password=123456

Sonar.sorceEncoding=UTF-8

Sonar.login=admin

Sonar.password=admin

Start after the configuration is completed. Startup file: sonarqube-7.4\ bin\ windows-x86-64\ StartSonar.bat

After the startup is completed, the following information is displayed to prove the success of the startup.

Access link: http://localhost:9000/, default username secret: admin/admin

As shown in the following figure, you can select the corresponding Chinese plug-in.

Next, configure the association between sonar-scanner-3.2.0 and mysql and related environment variables

Sonar-scanner-3.2.0\ conf\ sonar-scanner.properties

Text content:

#-Default SonarQube server

Sonar.host.url= http://localhost:9000

#-Default source code encoding

Sonar.sourceEncoding=UTF-8

Sonar.jdbc.url=jdbc:mysql:///sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

Sonar.jdbc.username=root

Sonar.jdbc.password=123456

Environment variable configuration:

Text content:

SONAR_SCANNER_HOME

Scanner installation directory:

C:\ Users\ sonar-scanner-3.2.0

The Path environment variable adds:

;% SONAR_SCANNER_HOME%\ bin

After the configuration is complete, run as administrator: sonar-scanner-v to see if the installation is successful.

Next, create the sonar-project.properties file under the root record of the project to be scanned, as follows:

Finally: the cmd administrator can execute sonar-scanner.

Log in to sonarQube to view:

Thank you for your reading, the above is the content of "SonarQube7.4 and sonar-Scanner-3.2.0 Environment Building method". After the study of this article, I believe you have a deeper understanding of the SonarQube7.4 and sonar-Scanner-3.2.0 environment building method, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Code environment plug-ins configuration analysis inspection methods content tests management variables data databases files quality learning detection complexity success next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info Microsoft Linux Xiaomi