Repository navigation
src: clear the two intentional empty-body CodeQL warnings - #59
Merged
Merged
Conversation
With the code-scanning bar now blocking a merge at any alert level, the two
intentional empty-control-body warnings had to go. Both rewritten to the same
behaviour without an empty body:
- ns.mc: 'if (ph_accept("\\", 1)) {}' -> 'ph_accept("\\", 1);' -- the
return was already discarded; this is the idiom class.mc:326,339 already use.
- rc.mc: the empty first branch of the if/else-if dispatch inverted by De
Morgan -- 'if (!(... php_str_repeat ...)) { if (php_str_setb) {...} else bad }'
-- equivalent: a php_str_repeat assignment still takes no fallback walk.
Behaviour-preserving (fixtures.sh green). minicompiler/codeql-mc's src/*.mc scan
is now clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Both rewrites are behaviorally equivalent and consistent with existing code patterns.
Review effort: Balanced
Findings: None
What changed in this PR
Removes two intentional empty-body patterns while preserving behavior and clearing CodeQL warnings.
Changes:
- Simplifies optional namespace separator consumption.
- Rewrites fresh-buffer dispatch without an empty branch.
| File | Description |
|---|---|
src/ns.mc |
Discards ph_accept’s result directly. |
src/rc.mc |
Inverts the dispatch while preserving fallback analysis. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the code-scanning merge bar raised to block at any alert level, the two remaining
empty-control-bodywarnings insrc/*.mc(intentional idioms, flagged byminicompiler/codeql-mc) would block every merge. Both are rewritten to the same behaviour with no empty body:ns.mcif (ph_accept("\\", 1)) {}→ph_accept("\\", 1);— the return was already discarded; this is the consume-if-present idiomclass.mc:326,339already use.rc.mcthe empty first branch of theif/else-ifdispatch, inverted by De Morgan:if (!(… php_str_repeat …)) { if (php_str_setb …) {…} else bad }. Equivalent — aphp_str_repeatassignment into the name still takes no fallback walk, any other call is walked or is a leak.Behaviour-preserving:
mc build+tests/fixtures.shgreen. After this, themcCodeQL scan oversrc/*.mcis clean (the 3 real findings were removed in #57; these were the 2 intentional ones).🤖 Generated with Claude Code