Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Panel
borderColor#888888#C3CCD7
bgColortitle#FCFCFC

Table of Contents

Table of Contents
maxLevel2
indent16px


If SonarQube's results aren't relevant, developers will push back on using it. That's why precisely configuring what to analyze for each project is a very important step. Doing so allows you to remove noise, like the issues and duplications marked on generated code, or the issues from rules that aren't relevant for certain types of objects.

SonarQube gives you several options for configuring exactly what will be analyzed. You can

  • completely ignore some files or directories
  • exclude files/directories from Issues detection (specific rules or all of them) but analyze all other aspects
  • exclude files/directories from Duplications detection but analyze all other aspects
  • exclude files/directories from Coverage calculations but analyze all other aspects

You can make these changes globally or at a project level. At both levels, the navigation path is the same: SonarQube가 분석한 결과가 만족스럽지 않다면--즉, 개발자 본인과 관계가 없다고 판단되면--, 개발자들은 더이상 SonarQube를 사용하지 않게 될 것입니다. 때문에 각 프로젝트를 어떻게 분석할지 세심하게 환경을 설정하는 것이 매우 중요합니다. 이를 통해 노이즈--중간 코드(generated code 즉, 중간 단계의 자동 생성 코드)에 표시된 이슈나 중복, 혹은 특정 타입의 객체와 관계없는 규칙으로 인한 이슈--를 줄일 수 있습니다.

SonarQube가 제공하는 여러가지 옵션을 활용해 어떤 대상을 분석할지 정확하게 설정할 수 있습니다. 에를 들면:

  • 특정 파일 혹은 디렉토리를 분석 대상에서 완전히 제외합니다.
  • 특정 파일/디렉토리를분석하지만, 해당 파일/디렉토리에서 이슈를 검출하지 않습니다(특정 혹은 모든 코팅 규칙에 대해).
  • 특정 파일/디렉토리를 분석하지만, 해당 파일/디렉토리에서 중복을 검출하지 않습니다.
  • 특정 파일/디렉토리를 분석하지만, 해다 파일/디렉토리에서 코드 커버리지를 계산하지 않습니다.

위 옵션은 global 혹은 project 레벨에서 설정 가능하며 Administration > General Settings > Analysis Scope를 사용합니다.

Ignore Files

We recommend that you exclude generated code, source code from libraries, etc. There are four different ways to narrow your analysis to the source code that will be relevant to the development team. You can combine them all together to tune your analysis scope.

Source Directories

Set the sonar.sources property to limit the scope of the analysis to certain directories.

File Suffixes

Most language plugins offer a way to restrict the scope of analysis to files matching a set of extensions. Go to 

파일 제외하기

중간 코드나 라이브러리 소스 코드 등은 분석 대상에서 제외할 것을 권장합니다. 네 가지 범위에서 분석 범위를 좁힐 수 있고, 네가 지 방법을 모두 조합할 수 있습니다.

소스 디렉토리

sonar.sources 속성을 설정해 특정 디렉토리만을 분석하도록 분석 범위를 지정합니다.

파일 확장자

대부분의 언어 플러그인은 특정 확장자를 가진 파일만을 분석하도록 기본 설정되어 있습니다.  Administration > General Settings > [Language] to set the File suffixes property.

Choosing Files

To specify which files are are and are not included in an analysis go to  에서 파일 확장자 속성을 설정할 수 있습니다.

직접 파일 선택하기

SonarQube가 특정 파일들만 분석 대상에 포함 혹은 포함하지 않도록 설정할 수 있습니다. Administration > General Settings > Analysis Scope  > > Files 메뉴를 사용합니다. Use exclusion to analyze everything but the specified files

특정 파일만 분석 대상에서 제외하고자 하는 경우, 다음 옵션을 사용합니다:

  • sonar.exclusions - to exclude source code files - 소스 코드 파일 을 제외합니다
  • sonar.test.exclusions - to exclude unit test files
Use inclusion to analyzes only the specified files
  • - 단위 테스트 파일을 제외합니다

특정 파일만 분석 대상에 포함하고자 하는 경우, 다음 옵션을 설정합니다:

  • sonar.inclusions  - 소스 코드 파일을 포함합니다
  • sonar.test.inclusions

You can set these properties at the project and global levels. 

See the Patterns section for more details on the syntax to use in these inputs.

See Also: Ignore Issues 

Ignore Issues

You can have SonarQube ignore issues on certain components and against certain coding rules. Go to 
  • - 단위 테스트 파일을 포함합니다

위 옵션은 global 및 project 레벨에서 설정할 수 있습니다. 옵션을 설정하기 위한 문법과 관련된 자세한 내용은 패턴 절 및 이슈 무시하기 절을 참조합니다.

Anchor
ignore-issues
ignore-issues
이슈 무시하기

SonarQube가 특정한 컴포넌트의 이슈 혹은 특정한 코딩 규칙을 위반한 이슈들을 무시하도록 설정할 수 있습니다. Administration > General Settings > Analysis Scope Scopte > Issues메뉴를 사용합니다.

Note that the properties below can only be set through the web interface because they are multi-valued.

Ignore Issues on Files

You can ignore all issues on files that contain a block of code matching a given regular expression.

Example: Ignore all issues on files containing 다음 속성들은 웹 인터페이스를 통해서만 설정할 수 있습니다.

파일의 이슈를 무시하기

입력한 정규 표현식(regular expression)과 일치하는 코드 플럭을 포함하는 모든 파일의 이슈를 무시하도록 설정할 수 있습니다. 

예: @javax.annotation.Generated를 포함한 모든 파일의 이슈를 무시:

Image Removed

Ignore Issues in Blocks

You can ignore all issues on specific blocks of code, while continuing to scan and mark issues on the remainder of the file. Blocks to be ignored are delimited by start and end strings which can be specified by regular expressions (or plain strings). 

Notes:

  • If the first regular expression is found but not the second one, the end of the file is considered to be the end of the block.
  • Regular expressions are not matched on a multi-line basis.

Ignore Issues on Multiple Criteria

You can ignore issues on certain components and for certain coding rules. To list a specific rule, use the fully qualified rule id shown in the rule detail:

Image Removed

Examples:

  • I want to ignore all issues on all files => key: *; path: **/*
  • I want to ignore all issues on COBOL program bank/ZTR00021.cbl => key: 

    Image Added

    블록의 이슈를 무시하기

    파일 내 특정 블록 상의 이슈만을 무시하도록 설정할 수 있습니다. 지정된 블록을 제외한 나머지 블록의 이슈는 무시하지 않습니다. 정규 표현식(혹은 일반적인 문자역)를 사용해 블록의 시작 및 종료 지점을 설정합니다.

    Notes:

    • 첫 번째 정규 표현식만 일치하고, 두 번째 정규 표현식이 일치하지 않는 경우 파일의 마지막까지를 블록으로 간주합니다.
    • 다중 라인에 대한 정규 표현식은 매칭시키지 않습니다.

    여러 기준을 조합하여 이슈를 무시하기

    특정한 코딩 규칙들에 대해 특정 컴포넌트에 발생한 이슈를 무시할 수 있습니다. 세부적인 규칙을 표시하기 위해서는 rule detail에 표시된 rule id를 사용해야 합니다:

    Image Added

    예: 

    • 모든 파일의 모든 이슈를 무시하고자 하는 경우=> key: *; path: */
    • COBOL 프로그램 bank/ZTR00021.cbl의 모든 이슈를 무시하고자 하는 경우=> key: *; path: bank/ZTR00021.cbl
    • I want to ignore all issues on classes located directly in the Java package com.foo, but not in its sub-packages Java 패키지 com.foo에 위치한 클래스의 모든 이슈는 무시, 하위 패키지의 이슈는 무시하지 않고자 하는 경우 => key: *;path:  comcom/foof oo/*I want to ignore all issues against coding rule
    • "object" 디렉토리 및 그 하위 디렉토리의 파일들에 대해 "cpp:Union" on files in the directory object and its sub-directories union" 코딩 규칙을 위반한 모든 이슈를 무시하고자 하는 경우=> key:  cpp:Union; path:  objectobject/**/*

    Restrict Scope of Coding Rules

    You can restrict the application of a rule to only certain components, ignoring all others.

    Examples:

    • I only want to check the rule Magic Number on Bean objects and not on anything else

    코딩 규칙 적용 범위 제한하기

    코딩 규칙의 적용 범위를 특정한 컴포넌트로 제한할 수 있습니다.

    예:


    • "Magic Number" 코딩 규칙을 "Bean" 객체에만 적용하고자 하는 경우=> key: checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck;path: **/*Bean.java
    • I only want to check the rule Prevent GO TO statement from transferring control outside current module on COBOL programs located in the directories "bank/creditcard and ", "bank/bankcard => this one requires two criteria to define it" 디렉토리에 위치한 COLBLE 프로그램에 대해서만 "Prement GO TO" 규칙을 적용하고자 하는 경우 => 이 경우 다음의 두가지 기준을 설정해야 함:
      • key: cobol:COBOL.GotoTransferControlOutsideCurrentModuleCheck; path: bank/creditcard/**/*
      • key: cobol:COBOL.GotoTransferControlOutsideCurrentModuleCheck; path: bank/bankcard/**/*

    Ignore Duplications

    You can prevent some files from being checked for duplications.

    To do so, go to 

    중복 무시하기

    지정한 파일에 대해 중복 검출을 무시하도록 설정할 수 있습니다.

    Administration > General Settings > Analysis Scope > Duplications and set the  메뉴에서 Duplication Exclusions property. See the Patterns section for more details on the syntax.

    Ignore Code Coverage

    You can prevent some files from being taken into account for code coverage by unit tests.

    To do so, go to  속성을 설정합니다. 옵션을 설정하기 위한 문법과 관련된 자세한 내용은 패턴 절을 참조합니다.

    코드 커버리지 무시하기

    지정한 파일에 대해 단위 테스트에 의한 코드 커버리지 계산을 무시하도록 설정할 수 있습니다. 

    Administration > General Settings > Analysis Scope > Code Coverage and set the  메뉴에서 Coverage Exclusions property. See the Patterns section for more details on the syntax.

    Patterns

    Paths are relative to the project base directory.

    The following wildcards can be used 속성을 설정합니다. 옵션을 설정하기 위한 문법과 관련된 자세한 내용은 패턴 절을 참조합니다

    Anchor
    patterns
    patterns
    패턴

    경로는 프로젝트 기준 디렉토리에 대한 상대경로입니다. 다음 와일드카드 문자를 사용할 수 있습니다:

    Wildcard

    Matches

    *
    zero or more characters
    0 혹은 그 이상의 문자
    **
    zero or more directories
    0 혹은 그 이상의 디렉토리
    ?
    a single character

    Relative paths are based on the fully qualified name of the component (like the one displayed in the red frame below):

    Image Removed

    .
    1 문자

    상대 경로는 해당 컴포넌트의 전체 경로를 기준으로 합니다(그림의 붉은 사각형 안에 표시된 경로 참조):

    Image Added


    Code Block
    languagebash
    titleExamples
    # Exclude all classes ending by "Bean"
    # Matches org/sonar.api/MyBean.java, org/sonar/util/MyOtherBean.java, org/sonar/util/MyDTO.java, etc.
    sonar.exclusions=**/*Bean.java,**/*DTO.java
     
    # Exclude all classes in the "src/main/java/org/sonar" directory
    # Matches src/main/java/org/sonar/MyClass.java, src/main/java/org/sonar/MyOtherClass.java
    # But does not match src/main/java/org/sonar/util/MyClassUtil.java
    sonar.exclusions=src/main/java/org/sonar/*
     
    # Exclude all COBOL programs in the "bank" directory and its sub-directories
    # Matches bank/ZTR00021.cbl, bank/data/CBR00354.cbl, bank/data/REM012345.cob
    sonar.exclusions=bank/**/*
     
    # Exclude all COBOL programs in the "bank" directory and its sub-directories whose extension is .cbl
    # Matches bank/ZTR00021.cbl, bank/data/CBR00354.cbl
    sonar.exclusions=bank/**/*.cbl