Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEV-000] sonarcloud 설정 추가 #193

Merged
merged 7 commits into from
Dec 2, 2024
Merged

[DEV-000] sonarcloud 설정 추가 #193

merged 7 commits into from
Dec 2, 2024

Conversation

5uhwann
Copy link
Collaborator

@5uhwann 5uhwann commented Nov 30, 2024

🚀 작업 내용

  • 소스코드 정적 분석을 위한 sonarcloud 설정을 추가
    • commnt패키지, request, response, command, query, dto 등 비즈니스 로직이 존재하지 않는 코드의 경우 측정을 제외했습니다.

🤔 고민했던 내용

💬 리뷰 중점사항

Summary by CodeRabbit

  • 새로운 기능

    • SonarCloud를 통한 코드 품질 분석을 위한 새로운 GitHub Actions 워크플로우 추가.
    • Gradle 빌드 구성에 Jacoco 및 SonarQube 플러그인 통합 및 관련 설정 추가.
  • 버그 수정

    • 코드 분석을 위한 환경 설정 및 종속성 캐싱 개선.

# Conflicts:
#	src/test/java/ddingdong/ddingdongBE/domain/club/service/FacadeCentralClubServiceImplTest.java
@5uhwann 5uhwann added ⚒️설정 설정 관련 이슈 D-0 labels Nov 30, 2024
@5uhwann 5uhwann self-assigned this Nov 30, 2024
Copy link

coderabbitai bot commented Nov 30, 2024

Walkthrough

이 변경 사항은 SonarCloud를 사용하여 프로젝트를 빌드하고 분석하는 새로운 GitHub Actions 워크플로 파일 sonar_cloud.yml을 도입합니다. 이 워크플로는 develop 브랜치에 푸시되거나 특정 풀 리퀘스트 이벤트가 발생할 때 트리거됩니다. 또한, build.gradle 파일에 Jacoco 및 SonarQube 플러그인을 추가하고 SonarQube 프로젝트에 대한 속성을 정의하는 새로운 구성 블록을 추가합니다.

Changes

파일 경로 변경 요약
.github/workflows/sonar_cloud.yml 새로운 GitHub Actions 워크플로 파일 추가, SonarCloud를 사용하여 빌드 및 분석 수행.
build.gradle Jacoco 및 SonarQube 플러그인 추가, SonarQube 속성 블록 및 jacocoTestReport 작업 추가.

Suggested labels

🌍인프라

Suggested reviewers

  • KoSeonJe

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 43420ff and b966434.

📒 Files selected for processing (1)
  • build.gradle (2 hunks)
🔇 Additional comments (5)
build.gradle (5)

5-6: SonarQube 플러그인 버전 업데이트가 필요합니다

현재 사용 중인 SonarQube 플러그인 버전(5.1.0.4882)이 최신 안정 버전보다 낮습니다. 보안 및 기능 개선을 위해 최신 버전으로 업데이트하는 것을 권장드립니다.


87-88: 테스트 후 자동으로 Jacoco 리포트를 생성하도록 설정된 것이 좋습니다

테스트 실행 후 자동으로 Jacoco 리포트가 생성되도록 finalizedBy를 사용한 것이 적절합니다.


Line range hint 5-129: SonarCloud 설정이 올바르게 작동하는지 확인이 필요합니다

설정이 올바르게 작동하는지 확인하기 위해 다음 사항들을 검증해보시기 바랍니다:

  1. Gradle 빌드 및 테스트 실행
  2. Jacoco 리포트 생성 확인
  3. SonarCloud 분석 실행 및 결과 확인

다음 명령어로 로컬에서 테스트해보실 수 있습니다:

./gradlew clean test
./gradlew sonar -Dsonar.login=your-token

90-109: 🛠️ Refactor suggestion

코드 커버리지 목표치 설정이 필요합니다

SonarCloud 분석의 품질을 보장하기 위해 다음 속성을 추가하는 것을 권장드립니다:

 sonar {
     properties {
+        property "sonar.coverage.minimum", "80"

또한 다음 속성들도 고려해보시기 바랍니다:

  • sonar.coverage.exclusions: 커버리지 측정에서 제외할 파일 패턴
  • sonar.test.inclusions: 테스트 파일 포함 패턴

Likely invalid or redundant comment.


111-129: 🛠️ Refactor suggestion

중복된 제외 패턴 리팩토링이 필요합니다

Sonar와 Jacoco 설정에서 동일한 제외 패턴이 중복되어 있습니다. 다음과 같이 공통 변수로 분리하여 재사용하는 것을 권장드립니다:

+def excludePatterns = [
+    "**/ddingdong/ddingdongBE/common/**",
+    "**/ddingdong/ddingdongBE/*Request*",
+    "**/ddingdong/ddingdongBE/*Response*",
+    "**/ddingdong/ddingdongBE/*Command*",
+    "**/ddingdong/ddingdongBE/*Query*",
+    "**/ddingdong/ddingdongBE/*Dto*"
+]

sonar {
    properties {
-        property "sonar.exclusions", [
-            "**/ddingdong/ddingdongBE/common/**",
-            ...
-        ].join(',')
+        property "sonar.exclusions", excludePatterns.join(',')
    }
}

jacocoTestReport {
    afterEvaluate {
        classDirectories.setFrom(files(classDirectories.files.collect {
            fileTree(dir: it, exclude: excludePatterns)
        }))
    }
}

Likely invalid or redundant comment.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (5)
.github/workflows/sonar_cloud.yml (3)

2-7: develop 브랜치에 대한 보호 규칙 추가 검토 필요

SonarCloud 분석이 develop 브랜치에 직접 푸시될 때도 실행되도록 설정되어 있습니다. develop 브랜치의 코드 품질을 보장하기 위해 직접 푸시를 제한하고 PR을 통해서만 변경되도록 브랜치 보호 규칙을 설정하는 것을 권장드립니다.


9-11: 작업 제한 시간 및 실패 알림 추가 필요

빌드 작업에 다음 설정들을 추가하는 것을 제안드립니다:

  1. timeout-minutes 설정으로 작업 시간 제한
  2. 작업 실패 시 알림 설정 (예: Slack)
jobs:
  build:
    name: Build and analyze
    runs-on: ubuntu-latest
+   timeout-minutes: 10

21-32: 캐시 보존 기간 설정 검토 필요

캐시 설정이 잘 되어 있으나, 장기간 누적되는 것을 방지하기 위해 캐시 보존 기간을 설정하는 것이 좋습니다.

      - name: Cache SonarCloud packages
        uses: actions/cache@v4
        with:
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
+         retention-days: 7
build.gradle (2)

5-5: SonarQube 플러그인 버전 업데이트 권장

현재 사용 중인 5.1.0.4882 버전은 최신 버전이 아닙니다. 보안 및 안정성 향상을 위해 최신 버전(5.2.1)으로 업데이트하는 것을 권장드립니다.

-    id "org.sonarqube" version "5.1.0.4882"
+    id "org.sonarqube" version "5.2.1"

88-94: SonarCloud 설정에 권장 속성 추가 제안

기본적인 SonarCloud 설정은 잘 구성되어 있습니다. 하지만 더 효과적인 코드 분석을 위해 다음과 같은 추가 속성들을 고려해보시기 바랍니다:

  • 테스트 커버리지 제외 패턴
  • 분석 제외 패턴
  • Java 버전 명시
sonar {
    properties {
        property "sonar.projectKey", "COW-dev_ddingdong-be"
        property "sonar.organization", "cow-dev"
        property "sonar.host.url", "https://sonarcloud.io"
+       property "sonar.coverage.exclusions", "**/test/**, **/Q*.java"
+       property "sonar.exclusions", "**/test/**, **/Q*.java"
+       property "sonar.java.source", "17"
    }
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6497982 and 4a2893c.

📒 Files selected for processing (2)
  • .github/workflows/sonar_cloud.yml (1 hunks)
  • build.gradle (2 hunks)
🔇 Additional comments (2)
.github/workflows/sonar_cloud.yml (2)

13-20: 코드 체크아웃 및 JDK 설정이 적절합니다

  • shallow clone을 비활성화하여 더 정확한 분석이 가능하도록 설정되었습니다
  • JDK 버전이 명시적으로 지정되어 있어 좋습니다

33-37: ⚠️ Potential issue

Sonar 설정 및 토큰 검증 필요

  1. sonar.properties 설정이 누락되어 있습니다. 프로젝트 키, 조직 등의 기본 설정이 필요합니다.
  2. SONAR_TOKEN secret이 저장소에 설정되어 있는지 확인이 필요합니다.

Copy link
Collaborator

@wonjunYou wonjunYou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨어요 ㅎㅎㅎ

Copy link
Collaborator

@KoSeonJe KoSeonJe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

.github/workflows/sonar_cloud.yml Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4a2893c and 43420ff.

📒 Files selected for processing (2)
  • .github/workflows/sonar_cloud.yml (1 hunks)
  • build.gradle (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/sonar_cloud.yml
🔇 Additional comments (1)
build.gradle (1)

87-88: 테스트 태스크 설정이 적절합니다

테스트 실행 후 자동으로 Jacoco 리포트가 생성되도록 설정된 것이 좋습니다.

build.gradle Show resolved Hide resolved
build.gradle Outdated Show resolved Hide resolved
build.gradle Outdated Show resolved Hide resolved
Copy link

sonarqubecloud bot commented Dec 2, 2024

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@5uhwann 5uhwann merged commit 10c30a6 into develop Dec 2, 2024
4 checks passed
@5uhwann 5uhwann deleted the test/DDING-000 branch December 2, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D-0 ⚒️설정 설정 관련 이슈
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants