Skip to content

feat: implement issue #349 — SonarCloud: shell script hygiene - #396

Merged
don-petry merged 10 commits into
mainfrom
dev-lead/issue-349-20260721-1922
Aug 2, 2026
Merged

feat: implement issue #349 — SonarCloud: shell script hygiene#396
don-petry merged 10 commits into
mainfrom
dev-lead/issue-349-20260721-1922

Conversation

@don-petry

@don-petry don-petry commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

User description

Closes #349

Implemented by dev-lead agent. Please review.

Summary by CodeRabbit

  • Bug Fixes

    • Made repository settings updates exit immediately after applying changes, avoiding unintended follow-up processing.
    • Standardized how “missing” status is reported when preferences or rulesets are absent, empty, or invalid.
  • Tests

    • Updated tests to use the shared “missing” sentinel for status-helper assertions.
    • Improved test helper flow with explicit success returns, making test execution more reliable.

CodeAnt-AI Description

Standardize repository settings checks and finish updates without unintended follow-up processing

What Changed

  • Repository settings checks now return one shared “missing” result when preferences, rulesets, or merge methods are absent or empty
  • Security and analysis updates now stop immediately after applying the requested changes
  • Shell test helpers return cleanly, and tests verify the shared missing-status result

Impact

✅ Consistent missing-status reporting
✅ No extra processing after settings updates
✅ More reliable shell test runs

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Copilot AI review requested due to automatic review settings July 21, 2026 19:27
@don-petry
don-petry requested a review from a team as a code owner July 21, 2026 19:27
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The repository settings script centralizes the missing status, applies it across two status helpers, and explicitly returns after the security-analysis API update. Tests use the shared sentinel and explicit success returns in helper functions.

Changes

Shell script hygiene

Layer / File(s) Summary
Status sentinel and function returns
scripts/apply-repo-settings.sh
Defines MISSING, uses it in status helpers, and returns after the security-analysis PATCH call.
Test helpers and status assertions
scripts/apply-repo-settings.test.sh
Test helpers explicitly return success, and missing-status expectations use the shared sentinel.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes appear to address the listed SonarCloud findings by adding explicit returns and replacing repeated 'missing' literals with a constant.
Out of Scope Changes check ✅ Passed No clear unrelated code changes are introduced beyond the shell-script hygiene fixes described in the issue.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the SonarCloud shell script hygiene changes described in the pull request objectives.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-349-20260721-1922

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a readonly MISSING constant in the test script to replace hardcoded strings, adds explicit return statements to test helper functions, and appends a bare return statement to the apply_security_and_analysis function. The feedback recommends removing the redundant bare return statement in the Bash script, as it is unnecessary and can be misleading regarding the function's exit status.

Comment thread scripts/apply-repo-settings.sh

Copilot AI 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

This PR addresses issue #349 by applying SonarCloud “shell script hygiene” fixes to the repo settings scripts/tests, aiming to reduce findings without changing runtime behavior.

Changes:

  • Added a MISSING constant in scripts/apply-repo-settings.test.sh and reused it across assertions to remove repeated string literals.
  • Added explicit return 0 statements to the test helper functions (pass, fail, assert_eq) to satisfy SonarCloud’s “explicit return” rule.
  • Added an explicit return at the end of apply_security_and_analysis() in scripts/apply-repo-settings.sh (preserving propagation of the gh api exit status).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
scripts/apply-repo-settings.test.sh Introduces a shared MISSING constant and adds explicit returns in helper functions to satisfy SonarCloud rules.
scripts/apply-repo-settings.sh Adds an explicit end-of-function return for SonarCloud shell hygiene compliance.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #396
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-07-21T20:09:51Z

@don-petry

Copy link
Copy Markdown
Contributor Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-07-21T20:09:51Z

@don-petry
don-petry enabled auto-merge (squash) July 21, 2026 19:39
@don-petry
don-petry disabled auto-merge July 21, 2026 20:07
@don-petry
don-petry enabled auto-merge (squash) July 21, 2026 20:07
donpetry-bot
donpetry-bot previously approved these changes Jul 21, 2026

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review — APPROVED ✓

Risk: LOW
Reviewed commit: 9175ad4df9227d339549515a7c3afd83a9da9e09
Review mode: triage-approved (single reviewer)

Summary

Small, mechanical shell-hygiene PR (2 files, +14/−6) resolving SonarCloud findings from issue #349. Adds explicit return statements (rule S7682) to pass, fail, and assert_eq in scripts/apply-repo-settings.test.sh and to apply_security_and_analysis in scripts/apply-repo-settings.sh, and introduces a readonly MISSING constant (rule S1192) replacing six repeated 'missing' literals. No behavior change.

Linked issue analysis

Issue #349 lists 4× S7682 and 1× S1192 across exactly these two files. The diff addresses all five findings: four explicit returns and one constant extraction. Acceptance criteria met — SonarCloud quality gate passed on this PR with 0 new issues, no NOSONAR suppressions used, and no behavior change: the bare return at the end of apply_security_and_analysis preserves the gh api exit status, and return 0 in fail() is added after the failure counter increment. Verified the sourced script never assigns a MISSING variable, so the readonly declaration before source cannot conflict.

Findings

No blocking findings.

  • Secret scan: run_secret_scanning MCP tool not available in this environment; gitleaks CI check passed (SUCCESS).
  • Bot reviews (gemini-code-assist, copilot) are COMMENTED, non-blocking. Gemini suggested removing the bare return in apply-repo-settings.sh as redundant — declining to act on it, since removing it would reintroduce the S7682 finding this PR exists to fix, and the bare return correctly propagates the last command's exit status.

CI status

All substantive checks green: gitleaks, CodeQL (actions + python), SonarCloud (quality gate passed, 0 new issues), AgentShield, dependency-audit, PR Review Agent. Two CANCELLED dev-lead check runs (dispatch, ci-relay) belong to a superseded Dev-Lead Agent run; a later run of the same check names completed SUCCESS/SKIPPED. Mergeable; merge state BLOCKED only pending required review.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@don-petry
don-petry disabled auto-merge July 21, 2026 21:24
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #396
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-07-21T21:55:28Z

@don-petry

Copy link
Copy Markdown
Contributor Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-07-21T21:55:28Z

@don-petry
don-petry enabled auto-merge (squash) July 21, 2026 21:25

@coderabbitai coderabbitai Bot 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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/apply-repo-settings.test.sh`:
- Around line 10-13: Move the MISSING constant from apply-repo-settings.test.sh
into apply-repo-settings.sh, then replace the repeated "missing" literals in
auto_trigger_status and pr_quality_merge_methods_status with that shared
constant. Update the tests to consume the sourced production value instead of
defining their own copy.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: edd12c4a-8ae5-426d-bd38-e158748031c5

📥 Commits

Reviewing files that changed from the base of the PR and between 3d6abee and 1d36677.

📒 Files selected for processing (2)
  • scripts/apply-repo-settings.sh
  • scripts/apply-repo-settings.test.sh

Comment thread scripts/apply-repo-settings.test.sh Outdated
@don-petry
don-petry disabled auto-merge July 21, 2026 21:26
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
- SonarCloud: ✓ SUCCESS
- All other substantive checks: ✓ SUCCESS or SKIPPED
- No Tier 1 blockers (no FAILURE, CHANGES_REQUESTED, or timed_out states)
**Review Threads:**
- Copilot & Gemini: COMMENTED (non-blocking overview/suggestion)
- donpetry-bot: DISMISSED (earlier automated review, already superseded)
- No CHANGES_REQUESTED reviews
## Conclusion
**No actionable issues to fix.** The PR has passed all quality gates with zero new issues and zero security hotspots. The SonarCloud bot comment is purely informational/confirmatory — it's reporting that the PR meets compliance standards.
The PR is in good state and ready to proceed. (Note: CodeRabbit is still in_progress, but other required checks have all passed.)

@don-petry
don-petry enabled auto-merge (squash) July 21, 2026 21:31
donpetry-bot
donpetry-bot previously approved these changes Jul 21, 2026

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review — APPROVED ✓

Risk: LOW
Reviewed commit: 83f3b0361a295164b7bb55a8fdf50bffdf9d4392
Review mode: triage-approved (single reviewer)

Summary

Mechanical shell-hygiene PR (2 files, +19/−13) resolving SonarCloud findings from issue #349. Introduces a readonly MISSING constant in scripts/apply-repo-settings.sh (rule S1192, replacing six 'missing' literals — jq expressions receive it via --arg) and adds explicit return statements to pass/fail/assert_eq in the test script and apply_security_and_analysis in the production script (rule S7682). No behavior change. Since the prior approved SHA (9175ad4, dismissed on push), the branch merged main and added one fix commit moving MISSING into the production script per CodeRabbit's review comment, which CodeRabbit confirmed as addressed (thread resolved).

Linked issue analysis

Closes #349 (SonarCloud: shell script hygiene — 4× S7682 explicit-return, 1× S1192 missing-constant). The diff addresses exactly these findings in exactly the two affected files, and the SonarCloud / SonarCloud Code Analysis checks pass on this PR, confirming the quality gate. Acceptance criteria (real fixes, no NOSONAR suppressions, no behavior change, CI green) are met.

Findings

  • No security-relevant changes: no auth/secrets/crypto/migrations/workflow edits (the dev-lead.yml delta in the compare range came from merging main, not this PR — changedFiles confirms only the two shell scripts).
  • Secret scan: run_secret_scanning MCP tool not available in this environment; gitleaks CI check passed and the diff contains no secret-like content.
  • One unresolved review thread remains: a low-priority gemini-code-assist nitpick claiming the bare 'return' in apply_security_and_analysis is redundant. The author replied with sound rationale — removing it would reintroduce the S7682 violation this PR exists to fix, and bare 'return' correctly propagates the gh api exit status. Answered, intentionally not acted on; not blocking.
  • Minor non-blocking nit: the test-file comment says constants are 'exported' by the production script — they are readonly and consumed via sourcing, not exported. Cosmetic only.
  • Note: branch is BEHIND main (mergeable; squash-merge ruleset will handle it).

CI status

All validation checks green: SonarCloud, SonarCloud Code Analysis, CodeQL (actions + python), gitleaks secret scan, AgentShield, pr-auto-review, review/review, CodeRabbit. Dependency-audit ecosystem jobs skipped (no matching ecosystems). Two dev-lead orchestration relay jobs show CANCELLED — these are agent-dispatch plumbing, not code validation.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@codeant-ai codeant-ai Bot added size:S This PR changes 10-29 lines, ignoring generated files and removed size:S This PR changes 10-29 lines, ignoring generated files labels Jul 24, 2026
@don-petry
don-petry disabled auto-merge July 24, 2026 14:12
@don-petry
don-petry enabled auto-merge (squash) July 24, 2026 14:14
@don-petry
don-petry disabled auto-merge July 24, 2026 14:14
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
- 0 CHANGES_REQUESTED
**Tier 1 blockers:** None present
## Conclusion
No actionable issues to address. The PR has:
1. Passed the SonarCloud quality gate with zero new findings
2. Cleared all CI checks 
3. Received approval with triage confirmation that the shell script hygiene fixes (MISSING constant + explicit returns per issue #349) are correctly implemented
4. Had feedback from code review bots already addressed in prior commits (per the donpetry-bot review noting "unresolved gemini-code-assist thread... Answered and non-blocking")
**Status:** ✓ Ready to merge
No changes required from this dev-lead audit.

@codeant-ai codeant-ai Bot added size:S This PR changes 10-29 lines, ignoring generated files and removed size:S This PR changes 10-29 lines, ignoring generated files labels Aug 2, 2026
@don-petry
don-petry disabled auto-merge August 2, 2026 00:43
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

@don-petry
don-petry enabled auto-merge (squash) August 2, 2026 00:45
@don-petry
don-petry disabled auto-merge August 2, 2026 00:45
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
- ✅ No failing or pending checks
- ✅ No CHANGES_REQUESTED reviews (donpetry-bot approved; others commented)
- ✅ Zero Tier 1 blockers
---
## Summary
**Bot:** SonarCloud  
**Issues addressed:** 0  
**Files changed:** None  
**Action taken:** None required
The SonarCloud quality gate passed with zero new issues, zero security hotspots, and no code findings. This PR has no actionable issues to address. All CI checks are passing, and the PR is already approved by the automated reviewer.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (no-changes)

Agent reasoning
Addressed 1 thread:
- Thread PRRT_kwDORsnIRM6Ss1O-: no code change — bare `return` is intentional per SonarCloud S7682 compliance; confirmed in reply and resolved bot thread [replied + resolved]
Test verification: pass — no code changes made; CI is fully green on this PR
Files changed: none
```

@don-petry
don-petry merged commit 5409ccb into main Aug 2, 2026
25 of 29 checks passed
@don-petry
don-petry deleted the dev-lead/issue-349-20260721-1922 branch August 2, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SonarCloud: shell script hygiene

3 participants