Skip to content

fix(tests): use ERE grep -E instead of BRE alternation, fix newline check (t143)#448

Merged
marcusquinn merged 1 commit intomainfrom
feature/t143
Feb 7, 2026
Merged

fix(tests): use ERE grep -E instead of BRE alternation, fix newline check (t143)#448
marcusquinn merged 1 commit intomainfrom
feature/t143

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 7, 2026

Summary

  • Replace 9 instances of grep '\|' (BRE alternation) with grep -E '|' (ERE) for improved readability and POSIX portability
  • Fix imprecise embedded-newline check at line 172: replaced grep -P '\x0a' pipeline (which couldn't reliably detect newlines in JSON keys) with python3 JSON key inspection
  • Extract duplicated git ls-files '*.sh' file-iteration logic into list_shell_scripts() helper function

Testing

  • bash -n syntax check: PASS
  • shellcheck: 0 issues
  • Full test suite: 55/56 pass (1 pre-existing unrelated failure: deployed script differs from repo)

Closes

Closes #442

Summary by CodeRabbit

  • Tests
    • Enhanced test robustness with improved pattern matching and code organization.
    • Replaced legacy matching approaches with more reliable alternatives.
    • Reduced test code duplication for better maintainability.

…heck (t143)

- Replace 9 instances of grep '\|' with grep -E '|' for readability
- Fix imprecise embedded-newline check to use python3 JSON key inspection
- Extract duplicated shell-script file iteration into list_shell_scripts()

Closes #442
@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 focuses on enhancing the reliability, readability, and maintainability of the test suite. It standardizes regular expression usage in grep commands for better portability and clarity, and significantly improves the accuracy of a critical JSON validation check. Additionally, it introduces a helper function to reduce code duplication, making the test script cleaner and easier to understand.

Highlights

  • Improved Grep Usage: Updated 9 instances of grep commands to use Extended Regular Expressions (ERE) with the -E flag and | for alternation, replacing the less readable and potentially less portable Basic Regular Expressions (BRE) with \|.
  • Reliable JSON Newline Check: Replaced an imprecise grep -P pipeline for detecting embedded newlines in JSON keys with a more robust python3 script, ensuring accurate detection of corrupted JSON structures.
  • Code Refactoring: Extracted the repetitive logic for listing Git-tracked shell scripts (git ls-files '*.sh') into a new helper function list_shell_scripts() to improve code reusability and readability within the test suite.
Changelog
  • tests/test-batch-quality-hardening.sh
    • Added a new helper function list_shell_scripts() to centralize the logic for listing all Git-tracked shell scripts.
    • Modified multiple grep commands (10 instances) to use grep -E for Extended Regular Expressions, replacing \| with | for alternation.
    • Replaced the grep -P based check for embedded newlines in JSON keys with a python3 script for more reliable detection.
    • Updated two sections that iterate over shell scripts to use the newly introduced list_shell_scripts() helper function, reducing code duplication.
Activity
  • The pull request was created by marcusquinn with a clear title and detailed description outlining the changes, testing, and related issue.
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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a helper function list_shell_scripts to consolidate shell script enumeration logic, and upgrades grep pattern syntax from BRE alternation (\|) to ERE (-E). Additionally replaces Perl regex patterns with Python-based or extended regex alternatives for improved portability and test robustness.

Changes

Cohort / File(s) Summary
Helper Function & Deduplication
tests/test-batch-quality-hardening.sh
Extracts list_shell_scripts helper function to enumerate git-tracked .sh files, replacing repeated inline git invocations across multiple test assertions.
Grep Pattern Syntax Upgrades
tests/test-batch-quality-hardening.sh
Replaces BRE alternation (grep 'a|b') with ERE syntax (grep -E 'a|b') for ~10 grep calls, improving POSIX portability and readability.
Perl Regex Replacements
tests/test-batch-quality-hardening.sh
Replaces grep -P (Perl-based) patterns with Python-based parsing or extended regex alternatives, including newline detection in JSON key validation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🛠️ From BRE to ERE, patterns now soar,
Helper functions streamline and restore,
Perl yields to Python's cleaner way,
Shell scripts shimmer—DevOps saved the day! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t143

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.

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Feb 7 17:58:49 UTC 2026: Code review monitoring started
Sat Feb 7 17:58:49 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 26
Sat Feb 7 17:58:49 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sat Feb 7 17:58:51 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 26
  • VULNERABILITIES: 0

Generated on: Sat Feb 7 17:58:51 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 7, 2026

marcusquinn added a commit that referenced this pull request Feb 7, 2026
@marcusquinn marcusquinn merged commit 473079b into main Feb 7, 2026
10 of 11 checks passed
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 introduces several good improvements. It standardizes on grep -E for better portability and readability, refactors duplicated script-listing logic into a helper function, and replaces a fragile grep pipeline with a robust Python script for JSON validation. My review includes a couple of suggestions to further refine the new helper function for better performance and to improve the Python script's resource management.

Comment on lines +53 to +55
list_shell_scripts() {
git -C "$REPO_DIR" ls-files '*.sh' | while read -r f; do echo "$REPO_DIR/$f"; done
}

Choose a reason for hiding this comment

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

medium

For improved conciseness and performance, especially with a large number of files, consider using sed to prepend the directory path instead of a while read loop. The shell loop invokes a new echo process for every file, which can be inefficient.

Suggested change
list_shell_scripts() {
git -C "$REPO_DIR" ls-files '*.sh' | while read -r f; do echo "$REPO_DIR/$f"; done
}
list_shell_scripts() {
git -C "$REPO_DIR" ls-files '*.sh' | sed "s,^,$REPO_DIR/,"
}

Comment on lines +179 to +182
import json, sys
d = json.load(open('$REPO_DIR/configs/pandoc-config.json.txt'))
bad = [k for k in d if '\n' in k]
sys.exit(1 if bad else 0)

Choose a reason for hiding this comment

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

medium

The embedded Python script opens a file but doesn't explicitly close it. While the operating system will clean this up for a short-lived script, it's a best practice to use a with open(...) statement to ensure resources are properly managed. This makes the code more robust and idiomatic.

Suggested change
import json, sys
d = json.load(open('$REPO_DIR/configs/pandoc-config.json.txt'))
bad = [k for k in d if '\n' in k]
sys.exit(1 if bad else 0)
import json, sys
with open('$REPO_DIR/configs/pandoc-config.json.txt') as f:
d = json.load(f)
sys.exit(1 if [k for k in d if '\n' in k] else 0)

marcusquinn added a commit that referenced this pull request Feb 7, 2026
…y errors (t147.2) (#451)

* chore: mark t142 complete in TODO.md (#449)

* chore: mark t135.9 complete in TODO.md (#448)

* fix(supervisor): triage PR #392 review feedback - stderr, sort, deploy errors (t147.2)

- Add post-PR states to ORDER BY CASE in cmd_status and cmd_list
- Add 300s timeout to deploy setup.sh with portable fallback
- Deploy failures now transition to 'failed' instead of silently marking 'deployed'
- Redirect cmd_pr_lifecycle output to post-pr.log instead of /dev/null
- Fix missing $SUPERVISOR_DB arg in db() calls for no_pr retry counter
- Remove unused no_pr_key variable

Dismissed 3 of 6 review threads as already fixed or invalid:
- gh pr merge stderr: already uses 2>&1
- Fallback PR lookup: already uses git -C and gh pr list --repo
- Missing pr_review:deployed transition: not needed, complete:deployed handles it
marcusquinn added a commit that referenced this pull request Feb 7, 2026
…147.1) (#450)

* chore: mark t142 complete in TODO.md (#449)

* chore: mark t135.9 complete in TODO.md (#448)

* fix(supervisor): add missing $SUPERVISOR_DB arg to db() calls, remove HOMEBREW_PREFIX guard (t147.1)

- Add $SUPERVISOR_DB as first arg to both db() calls in no_pr retry
  counter logic (lines 3165, 3183). Without it, sqlite3 treated the SQL
  as a filename and failed silently — retry counter never persisted,
  making the 5-attempt threshold unreachable.
- Remove unused no_pr_key variable.
- Remove HOMEBREW_PREFIX guard around PATH augmentation. The idempotent
  PATH check already prevents duplicates; the guard was overly
  restrictive for cron environments where HOMEBREW_PREFIX may be set
  without all tool paths present.

Triaged all 4 unresolved review threads from PR #435:
- 3 fixed (critical db bug, unused var, PATH guard)
- 1 acknowledged won't-fix (json_extract counter reset is by design)

Refs: GH#438, t147.1
@marcusquinn marcusquinn deleted the feature/t143 branch February 21, 2026 01:59
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.

t143: quality: test script uses BRE alternation instead of ERE (style improvement)

1 participant