refactor: extract shared getBinaryLogicalOperator helper - #597
Conversation
Extracts the byte-for-byte identical private getBinaryOperator method that was duplicated across csharpAnalyzer, goAnalyzer, javaAnalyzer, and rustAnalyzer into a single shared getBinaryLogicalOperator export in complexityHelpers.ts (alongside isOutermostInSameOperatorChain, which already lives there for the same reason). Pure refactor, no behavior change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #597 +/- ##
==========================================
+ Coverage 98.11% 98.19% +0.08%
==========================================
Files 12 12
Lines 3931 3885 -46
Branches 451 440 -11
==========================================
- Hits 3857 3815 -42
+ Misses 74 70 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The C# analyzer now has misleading stale JSDoc attached to getComplexityReason.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Centralizes logical binary-operator extraction without changing analyzer behavior.
Changes:
- Adds shared
getBinaryLogicalOperator. - Updates four analyzers and removes duplicate methods.
- Leaves stale C# JSDoc requiring cleanup.
File summaries
| File | Description |
|---|---|
complexityHelpers.ts |
Adds shared helper. |
csharpAnalyzer.ts |
Uses helper; removes duplicate. |
goAnalyzer.ts |
Uses helper; removes duplicate. |
javaAnalyzer.ts |
Uses helper; removes duplicate. |
rustAnalyzer.ts |
Uses helper; removes duplicate. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot Fix the code for all comments in this review thread. When a review comment includes a suggested change, apply the suggestion exactly. Do not make changes beyond what is described in the linked review thread. |
Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
Addressed in commit |
🤖 This PR was created by Repo Assist, an automated AI assistant.
What
Extracts the byte-for-byte identical
getBinaryOperatorprivate method that was duplicated acrosscsharpAnalyzer.ts,goAnalyzer.ts,javaAnalyzer.ts, andrustAnalyzer.tsinto a single sharedgetBinaryLogicalOperatorexport incomplexityHelpers.ts.Why
All four analyzers had the exact same logic (read child(1) of a
binary_expressionnode, check if its type is&&or||). This is the same class of duplication the repo already eliminated forisOutermostInSameOperatorChainin a previous pass — this helper was simply missed. Consolidating it in one place reduces maintenance surface and keeps the four analyzers consistent by construction.Trade-offs
Pure refactor, no behavior change. One previously-covered defensive
if (!operatorNode)branch became structurally unreachable from all four call sites combined (tree-sitter always emits an operator token for a validbinary_expression), so it now carries a/* c8 ignore next */annotation consistent with the existing pattern used for similar unreachable defensive branches elsewhere in this file.Test Status
npm run compile: ✅ cleannpm run lint: ✅ cleannpm run test:unit: ✅ 241/241 passing, coverage 98.76% stmts / 95.67% branches / 99.08% funcs / 98.76% lines (all above the configured.c8rc.jsonthresholds of 95/88/97/95)npm run test:vscode(integration): not run — blocked by sandboxed network (getaddrinfo EAI_AGAIN update.code.visualstudio.com), same known limitation as all previous Repo Assist runs in this environment.Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
releaseassets.githubusercontent.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run