Skip to content

refactor: extract shared addDetail helper across analyzers - #656

Merged
askpt merged 1 commit into
mainfrom
repo-assist/refactor-shared-adddetail-helper-20260919-d35107de17532faf
Sep 19, 2026
Merged

askpt merged 1 commit into
mainfrom
repo-assist/refactor-shared-adddetail-helper-20260919-d35107de17532faf

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This pull request was created by Repo Assist, an automated AI assistant.

Summary

javaAnalyzer.ts already had a private addDetail(increment, reason, line, column) helper that records a complexity detail and adds its increment to the running total. The other five analyzers (csharpAnalyzer.ts, goAnalyzer.ts, rustAnalyzer.ts, pythonAnalyzer.ts, jsLikeAnalyzer.ts) each repeated the identical 7-line pattern inline:

this.complexity += increment;
this.details.push({
  increment,
  reason,
  line: node.startPosition.row,
  column: node.startPosition.column,
  nesting: this.nesting,
});

at 8 call sites total (2x each in Go, Python, and jsLike).

Changes

  • Added a private addDetail(increment, reason, line, column) method to csharpAnalyzer.ts, goAnalyzer.ts, rustAnalyzer.ts, pythonAnalyzer.ts, and jsLikeAnalyzer.ts, mirroring the existing helper in javaAnalyzer.ts.
  • Replaced every inline this.complexity += ...; this.details.push({...}) block with a single this.addDetail(...) call.

Pure refactor — no behavior change, no new dependencies. Consistent with prior DRY extractions in this file family (isOutermostInSameOperatorChain, getBinaryLogicalOperator, hasLabelChild, findEnclosingTypeName).

Test Status

npm run compile   ✅ 0 errors
npm run lint      ✅ 0 warnings
npm run test:unit ✅ 250 passing, 0 failing

Coverage: 99.26% stmts / 96.38% branches / 100% functions / 99.26% lines (thresholds 95/88/97/95 met, unchanged from baseline).

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • releaseassets.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "releaseassets.githubusercontent.com"

See Network Configuration for more information.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@42c2ab5b4e4c9273534c39259b2e0df7f20f07e9

…sLike analyzers

Java's analyzer already had a private addDetail(increment, reason, line,
column) helper to record a complexity detail and add its increment to the
running total. The other five analyzers (C#, Go, Rust, Python, and the
shared JS/TS analyzer) each repeated the same 7-line
this.complexity += increment; this.details.push({...}) block inline at
8 call sites total, several duplicated 2x within the same file.

Extracted the same addDetail() helper into each of those analyzers,
matching Java's existing pattern, and replaced every inline occurrence
with a single call. Pure refactor, no behavior change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@askpt askpt changed the title [repo-assist] refactor: extract shared addDetail helper across analyzers refactor: extract shared addDetail helper across analyzers Sep 19, 2026
@codecov

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.78%. Comparing base (8eba5d1) to head (2b3696c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #656      +/-   ##
==========================================
+ Coverage   98.77%   98.78%   +0.01%     
==========================================
  Files          12       12              
  Lines        3920     3962      +42     
  Branches      438      438              
==========================================
+ Hits         3872     3914      +42     
  Misses         48       48              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@askpt
askpt marked this pull request as ready for review September 19, 2026 12:02
@askpt
askpt self-requested a review as a code owner September 19, 2026 12:02
Copilot AI balanced review requested due to automatic review settings September 19, 2026 12:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approved

The refactor consistently preserves the existing increments, locations, reasons, and nesting values.

Review effort: Balanced
Findings: None

What changed in this PR

Refactors complexity-detail recording across language analyzers without changing behavior.

Changes:

  • Adds consistent private addDetail helpers.
  • Replaces duplicated score/detail update blocks.
File Description
rustAnalyzer.ts Extracts detail recording helper.
pythonAnalyzer.ts Consolidates lambda and node detail updates.
jsLikeAnalyzer.ts Consolidates node and nested-function updates.
goAnalyzer.ts Consolidates node and alternative-branch updates.
csharpAnalyzer.ts Extracts detail recording helper.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@askpt
askpt merged commit 686076a into main Sep 19, 2026
25 checks passed
@askpt
askpt deleted the repo-assist/refactor-shared-adddetail-helper-20260919-d35107de17532faf branch September 19, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants