Programming
No. 743
Name. swindler
Subject. SonarQube
Main Cate. Java
Sub Cate. 개발일반
Date. 2014-01-17 11:42
Hit. 4336 (211.36.2...)
File.
http://www.sonarqube.org/

SonarQube는 품질관리를 할 수 있는 툴이라고 할 수 있다.

SonarQube는 크게 SonarQube와 SonarQube Runner로 나뉘어져 있으며, SonarQube는 웹 애플리케이션 서버 내에서 실행하는 war로 구성되어 있다. SonarQube는 대상 소스를 분석한 결과를 보여주는 웹화면들로 구성되어 있으며, SonarQube Runner는 대상 소스를 분석하는 명령어가 있다. 형상관리 도구로부터 소스를 가지고 와서 소스를 분석 후, SonarQube를 통해 결과를 DB에 저장하고 이를 SonarQube를 통해 보는 방식이다.



RPM base의 리눅스에서는 아래와 같이 binary 설치 가능하다.
sudo wget -O /etc/yum.repos.d/sonar.repo http://downloads.sourceforge.net/project/sonar-pkg/rpm/sonar.repo

yum install sonar


conf/sonar.properties에서 아래부분을 수정해야 한다.
sonar.jdbc.username=sonarqube
sonar.jdbc.password=mypassword
sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube

sonar.web.host=192.0.0.1
sonar.web.port=80
sonar.web.context=/sonar

참고로 2014년 1월 최신버전의 sonarqube에는 Java 6 이상이 필요하다.





sonar-runner를 사용하여 프로젝트를 분석할 수 있다.
conf/sonar-runner.properties 를 적당히 수정한다.

프로젝트 디렉토리에 sonar-project.properties 파일을 생성하고
아래와 같은 형태로 만든다.

# Required metadata
sonar.projectKey=my:javafind
sonar.projectName=javafind
sonar.projectVersion=1.0

# Paths to source directories.
# Paths are relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Do not put the "sonar-project.properties" file in the same directory with the source code.
# (i.e. never set the "sonar.sources" property to ".")
sonar.sources=WEB-INF/src

# The value of the property must be the key of the language.
sonar.language=java

# Encoding of the source code
sonar.sourceEncoding=UTF-8

# Additional parameters
sonar.my.property=value

그런 다음 그 폴더에서 sonar-runner를 실행한다.
(PATH에 추가하던가 절대경로를 입력하던가.)

소스가 100개 정도 되는데, 분석에 약 3분정도 소요됐다.
정상적으로 실행되고 나면, 웹화면에서 결과를 볼 수 있다.
(처음에만 3분정도 소요되고, 그 다음부터는 약 30초 정도)


Excluding Files
It is possible to exclude specific files from analysis. At the project level, go to Configuration > Settings > Exclusions > Files and set the:
sonar.exclusions property to exclude source code files
sonar.test.exclusions property to exclude unit test files
Global exclusions that will apply to all projects can also be set. Go to Settings > General Settings > Exclusions > Files and set the sonar.global.exclusions and sonar.global.test.exclusions properties.
Since version 3.5, you can also work the other way around by setting inclusions. Go to Settings > General Settings > Exclusions > Files and set the sonar.inclusions and sonar.test.inclusions properties to the list of files that should be analyzed. If you set an inclusion, then only the files or modules listed there will be included in the analysis.


Ignore Issues
You can have SonarQube ignore issues on certain components and against certain coding rules. Go to Configuration > Settings > Exclusions > Issues.
Note that the properties below can only be set through the web interface because they are multi-valued.



[바로가기 링크] : http://coolx.net/cboard/develop/743



Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox