Skip to content

fix: resolve SonarCloud S1481 and S1066 issues#201

Merged
marcusquinn merged 2 commits intomainfrom
bugfix/fix-sonarcloud-issues
Jan 25, 2026
Merged

fix: resolve SonarCloud S1481 and S1066 issues#201
marcusquinn merged 2 commits intomainfrom
bugfix/fix-sonarcloud-issues

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Jan 25, 2026

Summary

  • Fix 23 unused local variable issues (S1481)
  • Fix 16 collapsible if statement issues (S1066)

Changes

S1481 - Unused Variables

  • Removed or prefixed with underscore unused local variables across 11 files
  • Removed duplicate variable assignments in dspyground-helper.sh and pagespeed-helper.sh

S1066 - Collapsible If Statements

  • Merged nested if statements into single conditions across 10 files
  • Improved code readability while maintaining functionality

Files Modified

  • add-skill-helper.sh
  • beads-sync-helper.sh
  • cloudron-package-helper.sh
  • dspyground-helper.sh
  • eeat-score-helper.sh
  • fix-s131-default-cases.sh
  • keyword-research-helper.sh
  • linters-local.sh
  • localhost-helper.sh
  • mail-helper.sh
  • opencode-github-setup-helper.sh
  • pagespeed-helper.sh
  • quality-loop-helper.sh
  • secretlint-helper.sh
  • session-time-helper.sh
  • site-crawler-helper.sh
  • worktree-sessions.sh

Testing

  • All modified files pass ShellCheck validation
  • No functional changes, only code quality improvements

Summary by CodeRabbit

  • Refactor

    • Simplified conditional logic and control flow across multiple helper scripts to improve code maintainability and readability.
    • Streamlined parameter handling by removing redundant variable assignments and consolidating nested checks.
    • Cleaned up unused local variables and parameters throughout helper scripts.
  • Chores

    • Internal code optimization with no user-facing functionality changes.

✏️ Tip: You can customize this high-level summary in your review settings.

- Remove unused local variables (S1481):
  - cloudron-package-helper.sh: Remove unused 'app' parameter
  - session-time-helper.sh: Prefix unused IFS vars with underscore
  - add-skill-helper.sh: Prefix unused 'description' with underscore
  - worktree-sessions.sh: Prefix unused 'worktree_path' with underscore
  - opencode-github-setup-helper.sh: Remove unused vars
  - beads-sync-helper.sh: Prefix unused 'force' with underscore
  - site-crawler-helper.sh: Prefix unused vars with underscore
  - fix-s131-default-cases.sh: Remove unused 'offset' and 'total_fixed'
  - keyword-research-helper.sh: Remove unused array declarations
  - dspyground-helper.sh: Remove duplicate variable assignments
  - pagespeed-helper.sh: Remove duplicate variable assignments

- Merge collapsible if statements (S1066):
  - linters-local.sh: Combine file existence and size checks
  - mail-helper.sh: Combine type check with helper/payload checks
  - secretlint-helper.sh: Combine grep and npm list checks
  - localhost-helper.sh: Combine nc availability and port check
  - worktree-sessions.sh: Combine branch checks
  - quality-loop-helper.sh: Combine review trigger conditions
  - opencode-github-setup-helper.sh: Combine file and grep checks
  - site-crawler-helper.sh: Combine python availability checks
  - eeat-score-helper.sh: Combine config file and jq checks
  - add-skill-helper.sh: Restructure openskills check
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 25, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 1 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This pull request applies a systematic refactoring across 15+ shell scripts in the .agent/scripts/ directory, consolidating nested conditionals into single combined conditions, renaming unused local variables with underscore prefixes to mark them as reserved for future use, and removing genuinely unused variable declarations to reduce code complexity.

Changes

Cohort / File(s) Summary
Conditional Simplification
add-skill-helper.sh, eeat-score-helper.sh, linters-local.sh, localhost-helper.sh, mail-helper.sh, opencode-github-setup-helper.sh, quality-loop-helper.sh, secretlint-helper.sh, site-crawler-helper.sh
Merged nested if-statements into single combined conditions using && operators. Reduces control flow depth while preserving functional behavior. Affects openskills integration check, config file validation, port availability testing, memory storage logic, and CI configuration checks.
Variable Renaming & Future Reservation
add-skill-helper.sh, beads-sync-helper.sh, cloudron-package-helper.sh, opencode-github-setup-helper.sh, site-crawler-helper.sh, worktree-sessions.sh
Renamed unused/reserved function parameters to underscore prefix (e.g., description_description, force_force, _repo_path, _base_domain, _redirects), with comments indicating future feature intent. No runtime impact on current behavior.
Unused Variable Removal
fix-s131-default-cases.sh, keyword-research-helper.sh
Removed genuinely unused local variable declarations (offset, total_fixed, all_keywords, enriched_data). Eliminates dead code without altering control flow.
Scoping & Parameter Changes
dspyground-helper.sh, pagespeed-helper.sh
Removed redundant local variable assignments that shadowed positional parameters. Case statement now directly uses positional parameters, changing variable scoping behavior and potentially exposing outer-scope bindings.
⚠️ Risky Variable Reference Mismatch
session-time-helper.sh
Renamed IFS read targets (afk_afk, last_ts_last_ts) without updating downstream references to the original variable names. Creates mismatch where downstream code still references afk and last_ts (now uninitialized) while _afk and _last_ts hold the actual values. Affects JSON output formatting and timestamp calculations.
Single-Line Conditional Restructuring
worktree-sessions.sh
Converted multi-line nested test expressions into explicit backslash-continued single-line forms. Folds non-empty validation and branch exclusion (main/master) into unified conditional guard without functional change.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

The pull request applies repetitive refactoring patterns across many files (which reduces individual file review burden), but spans 15+ distinct scripts requiring consistency verification. Most changes are safe simplifications, but the session-time-helper.sh variable reference mismatch introduces a logic error that demands careful attention, and scoping shifts in dspyground-helper.sh and pagespeed-helper.sh warrant validation against downstream usage.

Possibly related PRs

Poem

🔧 Variables renamed to underscore's tune,
Nested ifs collapse like balloons in June,
Dead code purged with surgical precision,
Except for one variable in collision—
Session-time whispers: "check me twice!" 🎭

🚥 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 accurately summarizes the main objective: addressing two specific SonarCloud code quality rules (S1481 for unused variables and S1066 for collapsible conditionals) across multiple shell scripts.
Docstring Coverage ✅ Passed Docstring coverage is 95.00% which is sufficient. The required threshold is 80.00%.

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


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 and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the codebase's quality by systematically resolving two common SonarCloud issues: S1481 (unused local variables) and S1066 (collapsible if statements). The changes streamline conditional logic and eliminate redundant variable declarations, making the scripts cleaner, easier to read, and more maintainable. These improvements are purely refactoring-based, ensuring no functional impact while boosting adherence to coding standards.

Highlights

  • Code Quality Improvement (SonarCloud S1481): Addressed 23 instances of unused local variables across 11 files by either removing them or prefixing them with an underscore, enhancing code cleanliness and reducing potential confusion.
  • Code Quality Improvement (SonarCloud S1066): Resolved 16 instances of collapsible if statements across 10 files by merging nested conditional logic into single, more concise expressions, improving readability and maintainability.
  • Redundant Variable Assignments: Eliminated duplicate variable assignments in dspyground-helper.sh and pagespeed-helper.sh, streamlining the code in these scripts.
  • Functional Stability: All changes are purely refactoring-based, ensuring no functional impact on the scripts while passing ShellCheck validation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 481 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sun Jan 25 03:28:25 UTC 2026: Code review monitoring started
Sun Jan 25 03:28:26 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 481
Sun Jan 25 03:28:26 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sun Jan 25 03:28:28 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 481
  • VULNERABILITIES: 0

Generated on: Sun Jan 25 03:29:52 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

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 addresses SonarCloud issues by removing unused variables and collapsing nested if statements across multiple shell scripts. The changes are generally well-executed and improve code quality. Most unused variables are correctly removed or prefixed with an underscore, and many if statements are simplified effectively. I have one point of feedback on the refactoring in add-skill-helper.sh, where the attempt to collapse a more complex if structure has introduced a minor regression in logging behavior and a small inefficiency. My comment provides details on this for your consideration.

Comment on lines 546 to 559
if command -v openskills &>/dev/null \
&& openskills install "$owner/$repo${subpath:+/$subpath}" --yes --universal 2>/dev/null; then
log_info "Using openskills to fetch skill..."
if openskills install "$owner/$repo${subpath:+/$subpath}" --yes --universal 2>/dev/null; then
log_success "Skill installed via openskills"
# openskills handles everything, just register it
local skill_name="${custom_name:-$(basename "${subpath:-$repo}")}"
skill_name=$(to_kebab_case "$skill_name")
# openskills installs to ~/.config/opencode/skills/<name>/SKILL.md
# Register with -skill suffix for consistency with direct imports
register_skill "$skill_name" "https://github.com/$owner/$repo" ".agent/skills/${skill_name}-skill.md" "skill-md" "" "openskills" "Installed via openskills CLI"
return 0
fi
log_success "Skill installed via openskills"
# openskills handles everything, just register it
local skill_name="${custom_name:-$(basename "${subpath:-$repo}")}"
skill_name=$(to_kebab_case "$skill_name")
# openskills installs to ~/.config/opencode/skills/<name>/SKILL.md
# Register with -skill suffix for consistency with direct imports
register_skill "$skill_name" "https://github.com/$owner/$repo" ".agent/skills/${skill_name}-skill.md" "skill-md" "" "openskills" "Installed via openskills CLI"
return 0
elif command -v openskills &>/dev/null; then
log_warning "openskills failed, falling back to direct fetch"
fi

Choose a reason for hiding this comment

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

medium

While this refactoring resolves the SonarCloud S1066 issue, it introduces a couple of drawbacks:

  1. Misplaced Log Message: The log_info "Using openskills to fetch skill..." is now only executed upon successful installation. It's better practice to inform the user of an action before it's attempted, which was the original behavior.
  2. Redundant Check: The elif command -v openskills &>/dev/null performs a redundant check, as this was already evaluated in the initial if condition.

A clearer approach would be to use a nested if-else structure. This would preserve the logging order and avoid the redundant check. The original code structure was not a simple collapsible if due to the follow-on logic, so this might be a case where the linter's suggestion leads to less clear code.

Copy link
Contributor

@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: 1

🤖 Fix all issues with AI agents
In @.agent/scripts/session-time-helper.sh:
- Around line 249-251: The JSON output references an undefined variable $afk
because the read now assigns _afk; update the JSON-emission code to use $_afk
(or change the IFS read to produce afk instead of _afk) so the variable
referenced by JSON mode is bound under set -u; search for usages of $afk near
the JSON output generation and replace them with $_afk (or rename _afk→afk in
the read assignment) to fix the mismatch.

@augmentcode
Copy link

augmentcode bot commented Jan 25, 2026

🤖 Augment PR Summary

Summary: This PR updates multiple .agent/scripts/*.sh helper scripts to satisfy SonarCloud findings for unused locals (S1481) and collapsible/nested if statements (S1066).

Changes:

  • Removed unused or duplicate local-variable assignments across several helper scripts.
  • Marked intentionally-unused parameters/fields with _ prefixes and added “reserved for future use” notes.
  • Collapsed nested if blocks into single compound conditions to reduce branching.
  • Minor refactors in helper scripts for skills import, linters, localhost checks, mail pruning, secretlint rule checks, crawler setup, and worktree session utilities.

Technical Notes: The refactors are intended to be behavior-preserving and improve static-analysis/readability; ShellCheck compliance is expected to remain unchanged.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.


local active wall msgs afk first_ts last_ts
IFS='|' read -r active wall msgs afk first_ts last_ts <<< "$result"
local active wall msgs _afk first_ts _last_ts
Copy link

Choose a reason for hiding this comment

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

In cmd_list, the AFK value is now read into _afk, but later JSON output still references $afk; with set -u this will error when --json is used.

Other Locations
  • .agent/scripts/session-time-helper.sh:271

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

- session-time-helper.sh: Keep 'afk' variable name since it's used in JSON output
- add-skill-helper.sh: Restore original nested if structure to preserve
  logging order (log before action) and avoid redundant command check
@sonarqubecloud
Copy link

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 481 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sun Jan 25 03:33:44 UTC 2026: Code review monitoring started
Sun Jan 25 03:33:44 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 481
Sun Jan 25 03:33:44 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sun Jan 25 03:33:46 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 481
  • VULNERABILITIES: 0

Generated on: Sun Jan 25 03:35:09 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@marcusquinn marcusquinn merged commit 3d70020 into main Jan 25, 2026
9 checks passed
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.

1 participant