Skip to content

lint: gate repo on moongrep and fix some-catch-none-unwrap call sites - #1348

Draft
tonyfettes wants to merge 3 commits into
mainfrom
codex/moongrep-some-catch-none-unwrap
Draft

lint: gate repo on moongrep and fix some-catch-none-unwrap call sites#1348
tonyfettes wants to merge 3 commits into
mainfrom
codex/moongrep-some-catch-none-unwrap

Conversation

@tonyfettes

Copy link
Copy Markdown
Contributor

Summary

Adds a moongrep structural lint rule, wires it into CI, and fixes the seven existing call sites it flags.

What changed

  • Rule (.moongrep/rules/some-catch-none-unwrap.yaml): flags the (Some(x) catch { _ => None }) is Some(y) antipattern, where a raising call is wrapped in Some only to be immediately unwrapped.
  • Fixes: rewrites the seven matches to use try ... catch ... noraise (for skip/continue flow) or a direct catch with an early return (for guard ... else return None flow), so the success value is used directly.
  • CI (.github/workflows/ci.yml): a new lightweight moongrep job runs moonx moonbit-community/moongrep@0.1.18 -- scan --output-json and fails on any finding, making .moongrep/rules a CI-enforced contract.

Files touched

  • mcp/stdio/ndjson.mbt
  • mcp/streamhttp/transport.mbt
  • desktop/internal/codex/transport.mbt
  • editor/server/host/native_host.mbt
  • editor/server/host/language_provider.mbt

Validation

  • moon check clean for the affected modules (root, editor/server, desktop).
  • moon test mcp/stdio mcp/streamhttp: 9/9 pass.
  • moon fmt --check clean on all changed files.
  • moongrep scan reports 0 findings after the fixes.

Flag the (Some(x) catch { _ => None }) is Some(y) antipattern, where a raising call is wrapped in Some only to be immediately unwrapped.
Rewrite the seven call sites matching the new rule to use try ... catch ... noraise, or a direct catch with an early return, so the success value is used directly instead of being wrapped only to be immediately unwrapped.
Run moonx moonbit-community/moongrep@0.1.18 -- scan --output-json and fail when it reports any finding, so the .moongrep/rules files become a CI-enforced lint contract.
@tonyfettes
tonyfettes marked this pull request as ready for review September 7, 2026 09:26
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-07T09:31:57.165167Z 610d299 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tonyfettes
tonyfettes marked this pull request as draft September 7, 2026 09: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.

1 participant