SonarQube Official Doc Link: https://docs.sonarqube.org/display/SONAR/Analysis+Parameters
Table of Contents
프로젝트 분석 환경 설정을 위한 파라미터들은 다양한 위치에서 설정 가능합니다. 파라미터들은 다음과 같은 계층 구조를 가집니다:
- Global 분석 파라미터: UI에서 설정하며 모든 프로젝트에 적용됩니다(화면 최상단 bar 메뉴, Settings > General Settings).
- Project 분석 파라미터: UI에서 설정하며 global 파라미터의 설정 내용을 오버라이딩합니다(프로젝트 레벨, Configuration > Settings).
- Project 분석 파라미터: 프로젝트 분석 환경 설정 파일(sonar-project.properties) 혹은 분석 환경 파일(sonar.properties)에서 설정하며, UI에서 설정된 파라미터의 설정 내용을 오버라이딩합니다.
- Analysis / Command Line 파라미터: 분석 실행시 설정하며, project 분석 파라미터의 설정 내용을 오버라이딩 합니다.
UI에서 설정한 파라미터의 설정값들만 SonarQube 데이터 베이스에 저장됩니다.
예를 들어, `sonar.exclusions` 파라미터의 설정값을 커맨드 라인 명령어를 통해 오버라이딩해서 분석을 실행한 경우 해당 내용은 데이터베이스에 저장되지 않습니다. Eclipse를 통해 로컬 분석을 수행하는 경우, exclusion은 UI 상에서 설정되어 있기 때문에 해당 설정값는 데이터베이스에 저장됩니다.
본 섹션에서는 모든 파라미터를 기술하지 않습니다. 인터페이스에 표시되는 프로퍼티 키 역시 global, project 레벨 및 분석 파라미터로 설정할 수 있습니다
필수 파라미터
서버
Key | Description | Default value |
---|---|---|
sonar.host.url | SonarQube Server URL | http://localhost:9000 |
프로젝트 환경 설정
Key | Description | Default value |
---|---|---|
sonar.projectKey | 각 프로젝트가 고유하게 가지고 있는 key 값으로 다음의 문자열을 사용할 수 있습니다:
Maven을 사용하는 경우 key값은 자동으로 다음으로 설정됩니다: | |
sonar.sources | 콤마(',')로 구분된 디렉토리 명칭을 입력할 수 있습니다. Maven과 호환되나 그렇지 않은 경우 소스코드는 기본 Maven 코드 저장 위치에서 추출합니다. |
선택 파라미터
프로젝트 식별
Key | Description | Default value |
---|---|---|
sonar.projectName | SonarQube 웹 인터페이스에 표시되는 프로젝트 이름. Maven 프로젝트인 경우 < |
|
sonar.projectVersion | 프로젝트 버전. Maven 프로젝트인 경우 | 없음 |
인증
분석 수행권한이 없는 사용자로 로그인 한 경우, Execute Analysis 권한을 가진 사용자의 인증 정보를 입력해야 합니다.
Key | Description | Default value |
---|---|---|
sonar.login | Execute Analysis 권한을 가진 SonarQube 사용자의 로그인 계정 혹은 사용자 토큰. | |
sonar.password | sonar.login 사용자 계정의 비밀번호. 사용자 토큰을 사용하는 경우, 공란으로 남겨둡니다. |
웹 서비스
Key | Description | Default value |
---|---|---|
sonar.ws.timeout | 웹 소비스 콜의 최대 응답 대기시간(초) | 60 |
프로젝트 설정
Key | Description | Default value |
---|---|---|
sonar.projectDescription | 프로젝트 설명 | |
sonar.links.homepage | 프로젝트 홈페이지 링크 < url > 속성을 사용하는 Maven 프로젝트와 호환되지 않습니다. | |
Continuous integration < ciManangement ><url > 속성을 사용하는 Maven 프로젝트와 호환되지 않습니다. | ||
sonar.links.issue | 이슈 트래커 < issueManagement ><url > 속성을 사용하는 Maven 프로젝트와 호환되지 않습니다. | |
sonar.links.scm | 프로젝트 소스 링크 < scm ><url> 속성을 사용하는 Maven 프로젝트와 호환되지 않습니다. | |
sonar.links.scm_dev | 개발자 컨텍션 링크 < | |
sonar.tests | 콤마(',')로 구분된 테스트 케이스 파일의 경로 Java Maven 프로젝트의 기본 경로 정보를 사용하는 Maven 프로젝트와 호환되지 않습니다. | |
| 분석 대상 소스 코드 언어 설정 지원 가능한 프로그래밍 언어 리스트는 Plugin Library 페이지(영문)을 참조합니다. 별도로 설정하지 않을 경우 multi-language 분석을 수행합니다. |
|
| 소스 코드 파일 인코딩 설정
이 속성은 Maven 프로젝트의 project.build.sourceEncoding 속성으로 대체할 수 있습니다. 사용 가능한 인코딩은 JVM에 따라 상이합니다. 더 많은 정보는 http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html (column : Canonical Name for java.nio API)를 참조합니다(영문). | 시스템 설정 인코딩 |
| 분석 날짜 지정 Note: 이 속성은 특정한 유스케이스에서 활용할 수 있습니다:
위와 같은 유스 케이스에서 사용하고자 하는 경우 프로세스는 아래와 같습니다:
데이터베이스에 저장된 분석 결과 날짜 이전을 기준으 동일한 프로젝트를 분석할 수 없으며, 시간 순으로 분석할 수 있습니다. 따라서 오래된 버전일 수록 먼저 분석해야 합니다. ![]() | 현재 날짜 |
| SCM 브랜치를 관리합니다.
Developer Cockpit 플러그인 사용자인 경우, Developer Cockpit Installation and Usage (영문)의 "Limitation" 섹션을 참조합니다. |
|
| 해당 언어의 기본 프로파일 | |
| 분석을 시작한 디렉토리가 아닌 다른 디렉토리에서 분석을 해야할 경우--즉, 분석은 jenkins/jobs/myjob/workplace에서 시작했으니 ftpdrop/cobol/project의 코드를 분석해야 하는 경우 등--에 이 속성을 사용합니다. 경로는 절대 경로 혹은 상대 경로를 모두 사용할 수 있습니다. 소스 디렉토리가 아닌 소스 디렉토리의 부모 디렉토리를 지정합니다. 이 속성에 지정한 디렉토리는 새로운 "분석 디렉토리(analysis directory)"로 간주되며, 모든 다른 경로는 분석 프로세스를 진행하기 위해서는 이 디렉토리에 쓰기 권한을 가지고 있어야 하며, 이 디렉토리에는 | |
sonar.working.directory | SonarQube Scanner 혹은 SonarQube Ant Task (버전 2.0 이상) 분석 시 사용할 작업 디렉토리를 지정합니다. 경로는 각 프로젝트 별로 상이하며, 고유해야 합니다. 해당 폴더는 분석 시작 직전 삭제 됩니다. | .sonar |
sonar.scm.provider | This property can be used to explicitly tell SonarQube which SCM plugin should be used to grab SCM data on the project (in case auto-detection does not work). The value of this property is always lowercase and depends on the plugin (ex. "tfvc" for the TFVC plugin). Check the documentation page of each plugin to know more. | |
sonar.scm.forceReloadAll | By default, blame information is only retrieved for changed files. Set this property to true to load blame information for all files. This can be useful is you feel that some SCM data is outdated but SonarQube does not get the latest information from the SCM engine. | false |
Exclusions / Inclusions
See Narrowing the Focus to:
- Exclude files from analysis
- Prevent some files from being checked for duplications
- Prevent some files from being taken into account for code coverage by unit tests and integration tests
- Ignore issues on certain components and against certain coding rules
Key | Description | Default value |
---|---|---|
sonar.inclusions | Comma-delimited list of file path patterns to be included in analysis. When set, only files matching the paths set here will be included in analysis. | |
sonar.exclusions | Comma-delimited list of file path patterns to be excluded from analysis. | |
sonar.coverage.exclusions | Comma-delimited list of file path patterns to be excluded from coverage calculations | |
sonar.test.exclusions | Comma-delimited list of test file path patterns to be excluded from analysis. | |
sonar.test.inclusions | Comma-delimited list of test file path patterns to be included in analysis. When set, only test files matching the paths set here will be included in analysis. | |
sonar.issue.ignore.allfile | Files containing text matching this regular expression will be ignored by analysis. | |
sonar.import_unknown_files | If set to true, all files are imported - with respect to inclusions and exclusions, even if there is no matching language plugin installed. | false |
sonar.cpd.exclusions | Comma-delimited list of file path patterns to be excluded from duplication detection |
Duplications
Key | Description | Default value |
---|---|---|
sonar.cpd.exclusions | (see the Exclusions/Inclusions section) | |
sonar.cpd.${language}.minimumtokens | A piece of code is considered duplicated as soon as there are at least 100 duplicated tokens in a row (overide with sonar.cpd.${language}.minimumTokens ) spread on at least 10 lines of code (override with sonar.cpd.${language}.minimumLines ). For Java projects, a piece of code is considered as duplicated when there is a series of at least 10 statements in a row, regardless of the number of tokens and lines. This threshold cannot be overridden. | 100 |
sonar.cpd.${language}.minimumLines | 10 |
Analysis Logging
Key | Description | Default value |
---|---|---|
sonar.log.level | Control the quantity / level of logs produced during an analysis. DEBUG: TRACE: | INFO |
sonar.verbose | Add more detail to both client and server-side analysis logs.
| false |
sonar.showProfiling | Display logs to see where the analyzer spends time. This parameter is generating a file containing these timing infos in
| false |
sonar.scanner.dumpToFile | Outputs to the specified file the full list of properties passed to the scanner API as a means to debug analysis. |
Parameters specific to Integration
Those parameters are listed here for completeness of this documentation page - but regular users should not have to worry about them because they mainly target integration use cases.
Key | Description |
---|---|
sonar.analysis.mode | This parameter is set to |