1, the introduction of Sonarqube
Official website: https://www.sonarqube.org/
Sonarqube is an open platform for managing code quality.
1.1 Code quality can be detected from seven dimensions (why use Sonarqube)
(1) Complexity distribution (complexity): Code complexity is too high will be difficult to understand, difficult to maintain
(2) Duplicate code (duplications): The program contains a lot of copy and paste code is the performance of low quality
(3) Unit test (unit tests): Statistics and presentation of unit test coverage
(4) Coding specification (coding rules): written by Findbugs,pmd,checkstyle and other specification codes
(5) Note (comments): Less readability, more looks laborious
(6) Potential bug (potential bugs): detection of potential bugs through Findbugs,pmd,checkstyle, etc.
(7) Structures and designs (architecture & Design): dependence, coupling, etc.
Sonar can integrate different test tools, code analysis tools, continuous integration tools, and Ides.
sonar measures the results of code quality analysis by re-processing the data, by quantifying the way code quality changes, which makes it easy to code quality management of the project.
Supported languages include: Java, PHP, C #, C, Cobol, PL/SQL, Flex, and more.
Composition of the 1.2 Sonarqube platform
Database: Snapshot data that holds sonarqube configuration data, code quality
Web services: Snapshot data for viewing sonarqube configuration data, code quality
Parser: Analyze project code, generate quality result data and store it in database (parser has many, we choose SonarQube Maven Plugin)
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/8F/64/wKiom1jcudvREOVSAAGQyIIxK-4237.png "title=" 111. PNG "alt=" Wkiom1jcudvreovsaagqyiixk-4237.png "/>
2. Installation
2.1 Configuring MySQL
The engine that combines the Sonarqube,mysql database is best to use InnoDB to improve performance.
To view the current engine:
Mysql> show engines;
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/8F/6C/wKiom1jd0wuT33bWAABG65IhLPE998.png "title=" 1111. PNG "alt=" Wkiom1jd0wut33bwaabg65ihlpe998.png "/>
To view the current default engine:
Mysql> Show variables like '%storage_engine% ';
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/8F/6D/wKiom1jd06Sih53rAAASeRW95LM962.png "title=" 111. PNG "alt=" Wkiom1jd06sih53raaaserw95lm962.png "/>
Modify the MySQL storage engine for InnoDB, in configuration file/etc/my.cnf
[Email protected] ~]# vi/etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=my SQL # Disabling Symbolic-links is recommended to prevent assorted security risks symbolic-links=0 #加入这条default-st Orage-engine=innodb Default-storage-engine=innodb [Mysqld_safe] Log-error=/var/log/mysqld.log pid-file=/var/ru N/mysqld/mysqld.pid
Setting the innodb_buffer_pool_size parameter value
Set it as large as possible, the main function of this parameter is to cache the index of the InnoDB table, data, buffer when inserting data
Default value: 128M, the size of the dedicated MySQL server setting: Operating system memory 70%-80% best.
[[email protected] ~]# vi /etc /my.cnf [mysqld] datadir=/var/lib/mysql Socket=/var/lib/mysql/mysql.sock user=mysql # disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 default-storage-engine=INNODB #加入这条innodb_buffer_pool_size = 256M innodb_buffer_pool_size = 256m [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
Set query cache query_cache_size, set at least 15M
[[email protected] ~]# vi /etc /my.cnf [mysqld] datadir=/var/lib/mysql Socket=/var/lib/mysql/mysql.sock user=mysql # disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 default-storage-engine=INNODB innodb_buffer_pool_size = 256M #加入下面两条query_cache_type =1 query_cache_size=32m query_cache_type=1 query_cache_size=32m [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
After rebooting, verify that the cache settings are in effect
Mysql> Show variables like '%query_cache% ';
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/8F/6B/wKioL1jd3QHSjD46AAAhS_JDuLQ616.png "title=" 1111. PNG "alt=" Wkiol1jd3qhsjd46aaahs_jdulq616.png "/>
2.2 Creating a Sonarqube database (UTF8 encoding)
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/8F/6D/wKiom1jd3bnD87D3AAB2S3bPoGk160.png "title=" 111. PNG "alt=" Wkiom1jd3bnd87d3aab2s3bpogk160.png "/>
2.3 Install the Sonarqube webserver, use sonarqube-4.5.4.zip here
Press the solution and rename it to Sonarqube
[[email protected] opt] unzip sonarqube-4.5.4.zip [[email protected] opt] MV Sonarqube-4.5.4/sonarqube
To edit a database connection configuration:
[Email protected] sonarqube]# cd/opt/sonarqube/conf/[[email protected] conf]# VI sonar.properties #数据库用户名和密码 s Onar.jdbc.username=root sonar.jdbc.password=123456 #-----MySQL 5.x sonar.jdbc.url=jdbc:mysql://localhost:330 6/sonarqube?useunicode=true&characterencoding=utf8&rewritebatchedstatements=true&useconfigs= Maxperformance sonar.web.host=0.0.0.0 Sonar.web.context=/sonarqube sonar.web.port=9090
2.4 Starting SonarQube Web Server
/opt/sonarqube/bin/linux-x86-64/sonar.sh start
(The initial start will automatically build the table and do the corresponding initialization)
Browser input: http://192.168.175.9:9090/sonarqube/
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/8F/6B/wKioL1jd5DahZzWTAAChcX2P5TE458.png "title=" 111. PNG "alt=" Wkiol1jd5dahzzwtaachcx2p5te458.png "/>
Default User name/password is admin/admin
This article is from "I Love Big gold" blog, please be sure to keep this source http://1754966750.blog.51cto.com/7455444/1912062
Linux Learning: Continuous Integration chapter--sonarqube code Quality management Platform Introduction and installation-04