SonarQube Documentation_working

DISCLAIMER

  • 본 위키는 개인적으로 번역하여 제공하는 문서입니다. SonarQube의 개발사인 SonarSource로부터 번역에 대한 허가는 받았으나, 공식 계약 등에 따라 제공하는 문서가 아닙니다. 보다 자세한 내용은 SonarQube 공식 사용자 가이드(영문)을 참조하시기 바랍니다.
  • 이 문서는 SonarQube Documentation 9.6 버전을 기준으로 작성되었습니다.  


SonarQube는 셀프 매니지드 자동 코드 리뷰 도구이며, 체계적으로 클린 코드를 전달할 수 있도록 지원합니다. Sonar solution의 핵심 엘리먼트로서, SonarQube는 여러분의 기존 워크플로크에 통합되고, 코드의 이슈들을 식별함으로써 여러분이 지속적인 프로젝트의 코드 인스펙션을 수행할 수 있도록 돕습니다. 30개 이상의 프로그래밍 언어를 지원하며 여러분이 운용하는 CI pipeline과 DevOps platform에 통합되어 여러분의 코드가 높은 코드 기준을 만족함을 보장합니다.



클린 코드 작성하기


클린 코드를 작성하는 것은 건강한 코드 베이스를 유지하는 기본입니다. 클린 코드는 정의된 특정한 표준(예, 믿을 수 있는, 안전한, 유지 보수 가능한, 가독성이 좋은, 모듈화 및 다른 핵심 속성들)을 만족하는 코드라고 정의합니다. 클린 코드의 원칙은 소스 코드, 테스트 코드, 인프라스트럭처 애즈 코드, 글루 코드, 스크립트 등 모든 코드에 적용됩니다.

Sonar의 Clean as You Code 접근 방식은 개발 프로세스의 후반에서 코드를 리뷰하면서 발생하는 많은 문제들을 제거합니다. Clean as You Code 접근 방식에서는 Quality Gate를 사용해 새로운 코드(추가 또는 변경된 코드) 에 수정하거나 리뷰할 것이 있음을 알려줍니다. 이를 활용해 높은 표준을 유지하면서 코드 품질에 집중할 수 있습니다.


Sonar를 활용해 개발하기

Sonar가 제공하는 솔루션은 개발 프로세스의 모든 단계마다 확인을 수행합니다:

  • SonarLint 는 IDE에서 코드를 작성할 때 즉각적인 피드백을 주므로, 코드를 커밋하기 전에 이슈를 수정할 수 있습니다.
  • SonarQube의 PR analysis 를 사용하면 CI/CD 워크플로우 안에 SonarQube’s PR analysis을 포함시키고, Quality Gates 를 사용할 수 있습니다.
  • Quality Gates 는 이슈를 가진 코드가 프러덕션에 릴리스되는 것을 방지합니다. Clean as You Code 방법론을 적용하는 데 있어 핵심적인 요소입니다.
  • Clean as You Code 접근 방식은 프러덕션에 새로운, 깨끗한 코드를 제출하도록 도와주며, 시간이 지남에 따라 기존 코드 역시 개선됨을 알 수 있습니다.

SonarQube가 감지하는 이슈 유형에 관해 살펴봅니다.



Organizations start off with a default set of rules and metrics called the Sonar Way Quality Profile. This can be customized per project to satisfy different technical requirements. Issues raised in the analysis are compared against the conditions defined in the Quality Profile to establish your Quality Gate.

A Quality Gate is an indicator of code quality that can be configured to give a go/no-go signal on the current release-worthiness of the code. It indicates whether your code is clean and can move forward.

  • A passing (green) Quality Gate means the code meets your standard and is ready to be merged.
  • A failing (red) Quality Gate means there are issues to address.

SonarQube provides feedback through its UI, email, and in decorations on pull or merge requests (in commercial editions) to notify your team that there are issues to address. Feedback can also be obtained in SonarLint supported IDEs when running in Connected Mode. SonarQube also provides in-depth guidance on the issues telling you why each issue is a problem and how to fix it, adding a valuable layer of education for developers of all experience levels. Developers can then address issues effectively, so code is only promoted when the code is clean and passes the Quality Gate.