Skip to content

fix(skills): CodeQL code-quality — missing comma, empty except, unused import - #107

Open
risleylima wants to merge 2 commits into
bmad-code-org:mainfrom
risleylima:fix/codeql-python-quality-skills
Open

fix(skills): CodeQL code-quality — missing comma, empty except, unused import#107
risleylima wants to merge 2 commits into
bmad-code-org:mainfrom
risleylima:fix/codeql-python-quality-skills

Conversation

@risleylima

@risleylima risleylima commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Fixes #106. Clears the five GitHub Code Quality (CodeQL) findings that consumer repos inherit after installing BMad Builder skills under .agents/skills.

What was wrong

1. Implicit string concatenation in a list (py/implicit-string-concatenation-in-list) — warning

File: skills/bmad-agent-builder/assets/init-sanctum-template.py

Inside lines.extend([...]), two adjacent string literals sat next to each other without a comma:

"Prefer crafting your own tools over depending on external ones. A script you wrote "
"and saved is more reliable than an external API. Use the file system creatively.",

In a Python list/tuple display, that is implicit concatenation (one list element), which CodeQL flags because it usually means a missing comma between list items.

Fix: add the comma after the first string so they are two list elements (joined later by "\n".join(lines)):

"Prefer crafting your own tools over depending on external ones. A script you wrote ",
"and saved is more reliable than an external API. Use the file system creatively.",

2. Empty except without comment (py/empty-except) — note ×3

CodeQL requires an explanatory comment when an except body is only pass.

File Intent
bmad-module-builder/scripts/scaffold-standalone-module.py module.yaml metadata is optional; keep marketplace defaults if unreadable
bmad-*-builder/scripts/render_report.py (agent + workflow copies) Best-effort unlink of temp file before re-raising the original error

Fix: keep behavior; add one-line comments documenting the intentional swallow.

3. Unused import (py/unused-import) — note

File: skills/bmad-workflow-builder/scripts/tests/test_canon_sync.py

import sys was never used (__main__ only prints and asserts).

Fix: remove the import.

Test plan

Notes

These issues were byte-identical on main / v2.1.0; a BMAD quick-update alone would not have cleared them without this source fix.

Made with Cursor

Summary by CodeRabbit

  • Documentation

    • Added clarifying comments describing error handling, fallback behavior, and best-effort cleanup.
    • Documented that original errors continue to be preserved.
  • Chores

    • Improved formatting consistency in generated capability guidance.
    • Removed an unused import from the test suite.
    • No user-facing behavior or generated content changes.

Add the missing list comma to avoid implicit string concatenation,
document intentional empty except clauses, and drop unused sys import.
Fixes bmad-code-org#106.

Co-authored-by: Cursor <cursoragent@cursor.com>

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0967ff5c-09bb-4535-807b-353876712058

📥 Commits

Reviewing files that changed from the base of the PR and between 2edeaa8 and 2396786.

📒 Files selected for processing (4)
  • samples/bmad-agent-code-coach/scripts/init-sanctum.py
  • samples/bmad-agent-creative-muse/scripts/init-sanctum.py
  • samples/bmad-agent-sentinel/scripts/init-sanctum.py
  • skills/bmad-agent-builder/assets/init-sanctum-template.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/bmad-agent-builder/assets/init-sanctum-template.py

Walkthrough

The changes address CodeQL quality findings across builder skills. They document intentional exception handling, reformat unchanged generated strings, and remove an unused import. Runtime behavior remains unchanged.

Changes

Code quality cleanup

Layer / File(s) Summary
Code quality annotations and import cleanup
skills/bmad-agent-builder/..., skills/bmad-module-builder/..., skills/bmad-workflow-builder/..., samples/bmad-agent-*/...
Comments document best-effort cleanup and preserved marketplace defaults. Generated capability text remains unchanged after string reformatting. The unused sys import is removed.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 23967

This PR makes localized code-quality corrections without a supported merge-blocking correctness or operational risk; no actionable merge-blocking risk remains after normal checks and review.

Poem

A rabbit checks each builder line,
Comments make the intent shine.
Strings stay still, imports flee,
Errors keep their history.
Clean code hops happily.

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies the CodeQL quality fixes for string concatenation, empty exception handlers, and an unused import.
Linked Issues check ✅ Passed The changes address all five CodeQL findings listed in issue #106, including comments, string formatting fixes, and removal of the unused import.
Out of Scope Changes check ✅ Passed All changes support issue #106 by fixing or documenting the identified CodeQL findings in shipped skills and samples.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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 `@skills/bmad-agent-builder/assets/init-sanctum-template.py`:
- Line 170: Update the Tools guidance entries in the generated lines list so the
fragments ending with “wrote” and beginning with “and saved” remain one list
element without relying on implicit string concatenation. Preserve the resulting
single-line output when "\n".join(lines) generates CAPABILITIES.md.
🪄 Autofix

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: CHILL

Plan: Pro Plus

Run ID: 20b0551e-188f-4e5a-8f6e-3c9fdb8f1c5b

📥 Commits

Reviewing files that changed from the base of the PR and between e6935f2 and 2edeaa8.

📒 Files selected for processing (5)
  • skills/bmad-agent-builder/assets/init-sanctum-template.py
  • skills/bmad-agent-builder/scripts/render_report.py
  • skills/bmad-module-builder/scripts/scaffold-standalone-module.py
  • skills/bmad-workflow-builder/scripts/render_report.py
  • skills/bmad-workflow-builder/scripts/tests/test_canon_sync.py
💤 Files with no reviewable changes (1)
  • skills/bmad-workflow-builder/scripts/tests/test_canon_sync.py

Comment thread skills/bmad-agent-builder/assets/init-sanctum-template.py Outdated
@bmadcode

Copy link
Copy Markdown
Contributor

Thanks for taking a pass at the CodeQL noise. Four of the five hunks are good and I verified them against the query sources rather than taking them on faith: the two empty-except comments do satisfy py/empty-except (a comment anywhere in the except body clears it), and the sys import really is unused, with nothing in the __main__ block needing it.

The one in init-sanctum-template.py needs a different fix before this can go in. That implicit concatenation is intentional. The list is newline joined at line 178, so those two literals were one element, meaning one line of output. Adding the comma makes them two elements, so every generated CAPABILITIES.md now gets a line break in the middle of the sentence plus a stranded trailing space:

Prefer crafting your own tools over depending on external ones. A script you wrote 
and saved is more reliable than an external API. Use the file system creatively.

It also puts the generator out of step with assets/CAPABILITIES-template.md:28, which carries that sentence as one unbroken line.

Could you swap that hunk for a single merged literal:

"Prefer crafting your own tools over depending on external ones. A script you wrote and saved is more reliable than an external API. Use the file system creatively.",

That clears the alert and keeps the output identical. Parenthesizing the pair or joining with explicit + also work, and + is what #106 suggested, so any of the three is fine by me.

One more thing while you are in here, if you are willing. The same pattern exists in three shipped sample copies, and those go out to consumers through the sample-plugins marketplace entry:

  • samples/bmad-agent-code-coach/scripts/init-sanctum.py:166 and :175
  • samples/bmad-agent-creative-muse/scripts/init-sanctum.py:161
  • samples/bmad-agent-sentinel/scripts/init-sanctum.py:172

Fixing them in the same PR keeps the template and its copies consistent and actually clears the rule repo wide instead of one site of five.

Worth noting none of this is on you to have caught: there is no CodeQL or Python lint job in CI right now, so nothing here can tell a fix apart from a regression that silences the same alert. I'm tracking that separately.

…lines

Keep CAPABILITIES.md output as a single line by using one list element, and apply the same pattern to shipped sample init scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
@risleylima

Copy link
Copy Markdown
Author

Thanks for the review — the comma split was the wrong fix. Pushed a follow-up that merges those two literals into a single list element so "\n".join still emits one line, matching assets/CAPABILITIES-template.md.

Also folded in the extra py/implicit-string-concatenation-in-list sites you flagged in the shipped samples (same Tools sentence):

  • samples/bmad-agent-code-coach/scripts/init-sanctum.py (Tools line, plus the evolvable paragraph that was the same pattern split across three literals)
  • samples/bmad-agent-creative-muse/scripts/init-sanctum.py
  • samples/bmad-agent-sentinel/scripts/init-sanctum.py

Empty-except comments and the unused sys import are unchanged.

While scanning, I also saw implicit concatenation outside list displays (e.g. help= / print() in merge-config / eval-runner scripts). Left those alone — they are not in-list and would not change generated CAPABILITIES output. Happy to take them in a follow-up if you want the rule cleared repo-wide rather than just the list sites.

@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown

Greptile Summary

The PR resolves inherited CodeQL quality findings without changing runtime behavior.

  • Rewrites implicitly concatenated literals as single explicit strings across the template and samples.
  • Documents intentional exception swallowing during fallback and cleanup paths.
  • Removes an unused test import.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The string rewrites preserve generated text, the new comments do not affect exception behavior, and the removed import was unused.

Important Files Changed

Filename Overview
skills/bmad-agent-builder/assets/init-sanctum-template.py Replaces implicit literal concatenation with an equivalent single string while preserving generated output.
skills/bmad-agent-builder/scripts/render_report.py Adds an explanatory comment to the existing best-effort temporary-file cleanup path.
skills/bmad-module-builder/scripts/scaffold-standalone-module.py Documents the existing fallback behavior when optional module metadata cannot be read.
skills/bmad-workflow-builder/scripts/render_report.py Adds the same cleanup explanation as the agent-builder report renderer without changing behavior.
skills/bmad-workflow-builder/scripts/tests/test_canon_sync.py Removes an unused import with no effect on pytest or direct-script execution.
samples/bmad-agent-code-coach/scripts/init-sanctum.py Rewrites implicitly concatenated prose as an equivalent single literal.
samples/bmad-agent-creative-muse/scripts/init-sanctum.py Rewrites implicitly concatenated prose as an equivalent single literal.
samples/bmad-agent-sentinel/scripts/init-sanctum.py Rewrites implicitly concatenated prose as an equivalent single literal.

Reviews (1): Last reviewed commit: "fix(skills): merge implicit list concate..." | Re-trigger Greptile

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.

CodeQL code-quality: empty except, unused import, implicit string concat in builder skills

2 participants