Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux Learning: continuous Integration-- introduction and installation of sonarqube Code quality Management platform-04

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. SonarQube's introduction

Official website: www.sonarqube.org/

SonarQube is an open platform for managing code quality.

1.1 Code quality can be detected in seven dimensions (why SonarQube)

(1)Complexity: Code complexity is too high to understand and maintain

(2)Duplication: A program that contains a lot of copy-and-paste code is a sign of poor quality.

(3)Unit tests: Counting and displaying unit test coverage

(4)Coding rules: written by Findbugs,PMD,CheckStyle, etc.

(5)Comments: Less readable, more laborious

(6)Potential bugs: Detect potential bugs through Findbugs,PMD,CheckStyle, etc.

(7)Architecture & Design: Dependency, Coupling, etc.

Sonar can integrate different testing tools, code analysis tools, continuous integration tools, IDEs.

Sonar measures the change of code quality by re-processing the result data of code quality analysis and quantifying, so it can easily manage code quality of projects.

Supported languages include Java, PHP, C#, C, Cobol, PL/SQL, Flex, etc.

1.2 Components of SonarQube Platform

Database: SonarQube configuration data, snapshot data of code quality

Web services: configuration data for viewing SonarQube, snapshot data for code quality

Analyzer: analyze the project code, generate quality result data and store it in the database (there are many analyzers, we choose SonarQube Maven Plugin)

2. Installation

2.1 configure MySQL

Combined with SonarQube, Mysql database engines are best used with InnoDB to improve performance.

View current engine:

mysql> show engines;

View the current default engine:

mysql> show variables like '%storage_engine%';

Modify MySQL storage engine to InnoDB, in configuration file/etc/my.cnf

[root@localhost ~]# 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 #Add this entry default-storage-engine=INNODB default-storage-engine=INNODB [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid

Set innodb_buffer_pool_size parameter value

Set it as large as possible. This parameter is mainly used to cache the index and data of innodb table, and buffer when inserting data.

Default value: 128 MB, size of dedicated mysql server settings: 70%-80% of operating system memory is optimal.

[root@localhost ~]# 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 #Add this 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, at least 15 MB

[root@localhost ~]# 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 reboot, verify cache settings take effect

mysql> show variables like '%query_cache%';

2.2 Create sonarqube database (UTF8 encoding)

2.3 Install SonarQube's WebServer using sonarqube-4.5.4.zip

Compress and rename sonarqube

[root@localhost opt] unzip sonarqube-4.5.4.zip [root@localhost opt] mv sonarqube-4.5.4/ sonarqube

Edit database connection configuration:

[root@localhost sonarqube]# cd /opt/sonarqube/conf/ [root@localhost conf]# vi sonar.properties #Database username and password sonar.jdbc.username=root sonar.jdbc.password=123456 #----- MySQL 5.x sonar.jdbc.url=jdbc:mysql://localhost:3306/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 Start SonarQube Web Server

/opt/sonarqube/bin/linux-x86-64/sonar.sh start

(Initial startup will automatically create tables and initialize accordingly)

Browser input: 192.168.175.9:9090/sonarqube/

The default username/password is admin/admin

Set up self-start:

1. Create a new file/etc/init.d/sonar and enter the following:

#!/ bin/sh # # rc file for SonarQube # # chkconfig: 345 96 10 # description: SonarQube system (www.sonarsource.org) # ### BEGIN INIT INFO # Provides: sonar # Required-Start: $network # Required-Stop: $network # Default-Start: 3 4 5 # Default-Stop: 0 1 2 6 # Short-Description: SonarQube system (www.sonarsource.org) # Description: SonarQube system (www.sonarsource.org) ### END INIT INFO /opt/sonarqube/bin/linux-x86-64/sonar.sh $* exit $?

2. Authorize and add system services

chmod 755 /etc/init.d/sonar chkconfig --add sonar

The requested URL/opt/sonarqube/conf/wrapper.conf was not found on this server.

wrapper.java.command=/home/jdk1.7.0_71/bin/java

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report