Skip to content

chore: enable SonarCloud code quality analysis - #10

Merged
don-petry merged 7 commits into
mainfrom
chore/enable-sonarcloud
Mar 26, 2026
Merged

don-petry merged 7 commits into
mainfrom
chore/enable-sonarcloud

Conversation

@don-petry

@don-petry don-petry commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add SonarCloud configuration and GitHub Actions workflow
  • Runs code quality analysis on pushes to main and PRs
  • SonarCloud is free for open source projects

Setup required

  • Create SonarCloud project at sonarcloud.io for petry-projects/TalkTerm
  • Add SONAR_TOKEN secret to the repository settings

Test plan

  • Verify workflow triggers on next PR
  • Confirm SonarCloud analysis results appear

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Added automated SonarCloud analysis to run on pushes and pull requests targeting main.
    • Configured the workflow to run on Ubuntu with repository checkout and to use a SonarCloud token when provided.
    • Added project-level SonarCloud settings and exclusion patterns so scans respect configured project metadata and ignore specified paths.

Root and others added 2 commits March 25, 2026 21:50
Enable automated AI code reviews on pull requests with Python-specific
review instructions for best practices, type hints, and security.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add SonarCloud project configuration and GitHub Actions workflow
to run automated code quality analysis on pushes to main and PRs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot Bot review requested due to automatic review settings March 26, 2026 02:50

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds automated static analysis tooling to the repo via SonarCloud (plus a new CodeRabbit configuration file) to improve continuous code-quality feedback on main pushes and PRs.

Changes:

  • Add sonar-project.properties to configure SonarCloud project/org and analysis scope.
  • Add GitHub Actions workflow to run Sonar analysis on pushes to main and PRs targeting main.
  • Add .coderabbit.yaml to enable/configure automated CodeRabbit reviews.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
sonar-project.properties Defines SonarCloud project metadata and scan settings.
.github/workflows/sonarcloud.yml Runs Sonar scanning in GitHub Actions for pushes and PRs.
.coderabbit.yaml Enables/configures CodeRabbit automated PR reviews.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sonar-project.properties Resolved
Comment thread sonar-project.properties Resolved
Comment thread .github/workflows/sonarcloud.yml Resolved
Comment thread .coderabbit.yaml Resolved
Root and others added 3 commits March 25, 2026 22:05
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove deprecated sonar.language property (auto-detected)
- Add sonar.exclusions for _bmad-output/** and .claude/**
- Add if-guard to skip SonarCloud scan when token unavailable (fork PRs)
- Remove .coderabbit.yaml (belongs in separate PR #11)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolves SonarCloud security hotspot: "Use full commit SHA hash for
this dependency."

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

ghost commented Mar 26, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cf0dc6c0-b308-40bd-a09e-76c26925cc27

📥 Commits

Reviewing files that changed from the base of the PR and between 411fe3d and a5baaa1.

📒 Files selected for processing (1)
  • .github/workflows/sonarcloud.yml

📝 Walkthrough

Walkthrough

Adds a SonarCloud analysis CI workflow and project configuration: a GitHub Actions workflow runs SonarCloud scans on pushes and pull requests to main, and sonar-project.properties defines project metadata, sources, Python version, and exclusion patterns.

Changes

Cohort / File(s) Summary
CI workflow & Sonar config
/.github/workflows/sonarcloud.yml, sonar-project.properties
Adds a GitHub Actions workflow triggered on push and pull_request to main that checks out the repo (fetch-depth: 0), sets SONAR_TOKEN from secrets.SONAR_TOKEN, and runs SonarSource/sonarqube-scan-action@v6 when SONAR_TOKEN is present. Adds sonar-project.properties with sonar.projectKey=petry-projects_TalkTerm, sonar.organization=petry-projects, display name TalkTerm, sonar.sources=., sonar.python.version=3.11, and exclusions _bmad-output/** and .claude/.

Sequence Diagram(s)

sequenceDiagram
    actor Developer
    participant GitHub as "GitHub Actions (runner)"
    participant Repo as "Repository (checkout)"
    participant Sonar as "SonarCloud action"
    Developer->>GitHub: push or open PR to main
    GitHub->>Repo: checkout (fetch-depth: 0)
    GitHub->>GitHub: load secrets (SONAR_TOKEN)
    alt SONAR_TOKEN present
        GitHub->>Sonar: invoke SonarSource/sonarqube-scan-action@v6
        Sonar->>Sonar: analyze code (uses sonar-project.properties)
        Sonar-->>GitHub: report analysis results
    else SONAR_TOKEN missing
        GitHub-->>Developer: skip SonarCloud step
    end
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: enable SonarCloud code quality analysis' directly and clearly describes the main change—adding SonarCloud configuration and GitHub Actions workflow for code quality analysis.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/enable-sonarcloud

Comment @coderabbitai help to get the list of available commands and usage tips.

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/sonarcloud.yml:
- Around line 1-11: Add an explicit minimal permissions block at the top-level
of the workflow (after the on: block) to avoid relying on repo defaults; for
this SonarCloud job add something like permissions: contents: read,
pull-requests: write, actions: read (or the exact least-privilege set your org
requires) so the sonarcloud job (job name "sonarcloud") only has the necessary
token scopes rather than full default permissions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2fc8073b-984f-4f4c-aa38-cd359a4341c4

📥 Commits

Reviewing files that changed from the base of the PR and between ec5e327 and 37b2359.

📒 Files selected for processing (2)
  • .github/workflows/sonarcloud.yml
  • sonar-project.properties

Comment thread .github/workflows/sonarcloud.yml Resolved
Pins minimal token permissions (contents: read, pull-requests: read)
instead of relying on repo/org defaults.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/sonarcloud.yml:
- Around line 19-22: The step-level env defines SONAR_TOKEN but the step's if:
condition reads env.SONAR_TOKEN before step env is available; move the
SONAR_TOKEN secret up to the job-level env (so env: SONAR_TOKEN: ${{
secrets.SONAR_TOKEN }} is defined on the job) and remove the SONAR_TOKEN entry
from the SonarSource/sonarqube-scan-action step; keep the step's if: condition
as if: env.SONAR_TOKEN != '' and retain the uses:
SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602
reference.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6df6905c-2eaf-4ef7-ada4-23add43b1e9d

📥 Commits

Reviewing files that changed from the base of the PR and between 37b2359 and 411fe3d.

📒 Files selected for processing (1)
  • .github/workflows/sonarcloud.yml

Comment thread .github/workflows/sonarcloud.yml Resolved
Step-level env is not available during if evaluation. Move secret to
job-level env so the step's if condition can properly gate execution
on fork PRs where the secret is unavailable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sonarqubecloud

ghost commented Mar 26, 2026

Copy link
Copy Markdown

@don-petry
don-petry merged commit 7f70d2a into main Mar 26, 2026
@don-petry
don-petry deleted the chore/enable-sonarcloud branch March 26, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants