refactor: extract floopDirExists and logDecision helpers#263
refactor: extract floopDirExists and logDecision helpers#263nvandessel merged 5 commits intomainfrom
Conversation
Extract floopDirExists(root) bool in cmd_hook.go to replace 4 instances of filepath.Join + os.Stat + os.IsNotExist. Add logDecision(fields) method on SubagentClient in subagent.go to encapsulate the nil-check on the decisions logger, replacing 7 occurrences. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR is a clean refactoring that eliminates two categories of repeated boilerplate: a
Confidence Score: 5/5Safe to merge — pure refactoring with no behavioural changes and full test coverage of the new helper paths. All changes are mechanical de-duplication with semantics verified to be identical to the original code. No new logic, no changed error handling, no new dependencies. No files require special attention.
|
| Filename | Overview |
|---|---|
| cmd/floop/cmd_hook.go | Extracts floopDirExists helper replacing 4 identical os.Stat/os.IsNotExist patterns; semantics fully preserved |
| internal/llm/subagent.go | Adds logDecision method encapsulating the nil-guard on c.decisions, replacing 7 identical blocks cleanly |
| internal/llm/subagent_test.go | Adds test covering the CLI not found decision-log path; follows the established test pattern in the file |
Reviews (4): Last reviewed commit: "Merge branch 'main' into refactor/hook-a..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #263 +/- ##
==========================================
+ Coverage 78.58% 78.68% +0.09%
==========================================
Files 185 185
Lines 18706 18702 -4
==========================================
+ Hits 14700 14715 +15
+ Misses 2773 2755 -18
+ Partials 1233 1232 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Covers the logDecision call in detectAvailability when inCLISession() returns true but findCLI() returns empty, achieving 100% patch coverage for the logDecision helper refactoring. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rename `new` parameter to `incoming` in mergeSourceEvents to avoid shadowing Go built-in (P2-1) - Remove unnecessary intermediate pointer in executeAbsorb — use value returned by getTargetNode directly (P2-2) - Add tests for DuplicateContentError.Error() and Is() methods - Add tests for getTargetNode, mergeSourceEvents helpers - Add tests for unknown merge strategy and skip path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DuplicateContentError is defined in PR #264, not this branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
floopDirExists(root string) boolhelper incmd/floop/cmd_hook.goto replace 4 repeatedfilepath.Join+os.Stat+os.IsNotExistcheckslogDecision(fields map[string]any)method onSubagentClientininternal/llm/subagent.goto encapsulate the nil-check on the decisions logger, replacing 7 occurrencesTest plan
go vet ./cmd/floop/... ./internal/llm/...— cleango test ./internal/llm/...— all passgo test ./...— only pre-existing build failures (CGO lancedb linker, consolidation promote.go)go fmt ./...— clean🤖 Generated with Claude Code