Skip to content

refactor: inline single-caller snippetFor, hoist htmlHeaders to const#7

Merged
PeterM45 merged 1 commit into
mainfrom
refactor/inline-single-caller-helpers
Jun 15, 2026
Merged

refactor: inline single-caller snippetFor, hoist htmlHeaders to const#7
PeterM45 merged 1 commit into
mainfrom
refactor/inline-single-caller-helpers

Conversation

@PeterM45

@PeterM45 PeterM45 commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Two micro-simplifications from a ponytail over-engineering audit. No behavior change.

  • snippetFor() only delegated to SNIPPETS[target] with one caller — inlined, function removed (src/cli.ts).
  • htmlHeaders() built an identical object on every call (2 callers, never varies) — hoisted to a shared HTML_HEADERS const (src/core.ts).

Net ~-8 lines. typecheck + biome clean, 155/155 tests pass.

Summary by CodeRabbit

  • Refactor
    • Consolidated shared configuration settings to reduce code duplication.
    • Simplified internal logic for improved code maintainability.

snippetFor() only delegated to SNIPPETS[target] with one caller; inline it.
htmlHeaders() built an identical object on every call; make it a shared
HTML_HEADERS const. No behavior change.
@coderabbitai

coderabbitai Bot commented Jun 15, 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: ASSERTIVE

Plan: Pro

Run ID: edbc28ce-e3e9-4af2-bd45-a95b20d6001a

📥 Commits

Reviewing files that changed from the base of the PR and between 0e7aefa and 6b93b14.

📒 Files selected for processing (2)
  • src/cli.ts
  • src/core.ts

📝 Walkthrough

Walkthrough

Two one-liner helper functions are eliminated: snippetFor(target) in src/cli.ts is replaced by a direct SNIPPETS[target] index, and htmlHeaders() in src/core.ts is replaced by a module-level HTML_HEADERS constant reused across both HTML response sites.

Changes

Helper inlining refactor

Layer / File(s) Summary
Remove snippetFor helper
src/cli.ts
runInit now logs SNIPPETS[target] directly; the one-line snippetFor function is deleted.
Replace htmlHeaders() with HTML_HEADERS constant
src/core.ts
A static HTML_HEADERS record replaces the htmlHeaders() helper; loginPage and notConfiguredPage both reference the constant.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A helper or two, gone with a snip,
Direct references now take the trip.
No function to call, no wrapper to need,
Just constants and indexes—clean and freed.
Fewer hops, same result, the rabbit agrees! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 accurately describes the main refactoring changes: inlining a single-caller helper function and converting a repeated initialization into a constant.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/inline-single-caller-helpers

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 and usage tips.

@PeterM45 PeterM45 merged commit 3dc507d into main Jun 15, 2026
6 checks passed
@PeterM45 PeterM45 deleted the refactor/inline-single-caller-helpers branch June 15, 2026 20:27
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