Home > Archives > 代码检查sonar

代码检查sonar

Publish:

MYSQL CREATE DATABASE

1
2
3
CREATE DATABASE sonarqube
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;

INSTALL SONAR

1
2
3
wget -O /etc/yum.repos.d/sonar.repo http://downloads.sourceforge.net/project/sonar-pkg/rpm/sonar.repo

yum install -y sonar

UPDATE CONFIGURATION

1
2
3
4
5
6
7
8
9
10
11
12
13
14
vim /opt/sonar/conf/sonar.properties

sonar.jdbc.username=root
sonar.jdbc.password=*****

sonar.jdbc.url=jdbc:mysql://192.168.10.xxx:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false

systemctl enable sonar.service

systemctl start sonar.service

http://192.168.10.xxx:9000/
username:admin
password:admin

UPDATE MAVEN CONFIGRATION

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
vim /usr/share/maven/conf/settings.xml

<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>

<profile>
	<id>sonar</id>
	<activation>
		<activeByDefault>true</activeByDefault>
	</activation>
	<properties>
		<sonar.host.url>
		http://localhost:9000
		</sonar.host.url>
	</properties>
</profile>

COMPILE

1
mvn clean install

PUSH TO SERVER

1
mvn sonar:sonar

在 CentOS 7 與程式碼品質分析工具 SonarQube 相遇

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: Ding Bao Guo