Skip to content

refactor: simplify code churned through 0.10.0 - #442

Merged
ryanlewis merged 32 commits into
mainfrom
refactor/simplify
Oct 10, 2026
Merged

ryanlewis merged 32 commits into
mainfrom
refactor/simplify

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

Cleanups from a /simplify sweep over the code that changed between v0.9.0 and HEAD. Everything is meant to keep behaviour the same: no command, flag, output, error text or exit code changes, and no golden or testdata files changed. make test and make lint pass.

Import

  • Refusal categories live in one ordered table instead of ten parallel fields kept in step across five places. A throwaway golden test confirmed Error() text and --json items match the old code byte for byte.
  • resolveImportDests becomes a destResolver struct with small methods.
  • Bad and future date checks are merged, so each date parses once; a problems type replaces the parallel lines/names slices; one jsonText helper replaces six json.Marshal copies.
  • Read-back reasons (not-found, ambiguous, ...) are named constants, including the unconfirmedMsg keys.
  • createdWhere and confirmedRow replace duplicated filter and lookup loops.

Other commands

  • complete/cancel go through applyEdit; applyStatusWrite and verifyStatus are gone.
  • runEdit inlines two single-use wrappers for the "changed" test.
  • Shared knownHeadingID, Deps.dbPath, and one branch for open's --project and positional ref.

internal/db

  • The list query uses notATemplate; the comment saying it couldn't was wrong.
  • widensStatus names the status widening rule once; foldsUnlogged is an argument rather than an option no caller set.
  • Reuse FoldTag/foldAreaRef, queryAll for checklist items, untrashedRows; scanProject drops a dead NULL guard.

output / things / config

  • Table rows are joined in one pass without lipgloss.JoinHorizontal; the compact date is only built on a TTY.
  • ThingsDate.Date() shared by ToTime and daysFromToday; styledProjectIcon reuses styledStatus.
  • Smaller: one date-time layout, setNonEmpty/setBool reuse, a package-level AppleScript escaper, a shared length check, a shared config bool lookup.

Skipped

  • Building GetTask's substring step from the folded candidates: not equivalent for NULL status/trashed rows or an empty reference.
  • Folding dbtest.Recurrence into Repeats: db tests call it directly.
  • A generic interface for runEdit's parameters, sharing the tag add loop, splitting tasks.go: not worth it.

…alue

badImportDates and futureImportDates become importDates, which parses each date attribute once.
Each refused item keeps its lines by kind, so reason(), Error() and the blocked list loop over the table instead of naming ten fields in lockstep.
The other-items paragraph now checks for an item that does not fail directly; the missing, dropped and misfiled sets are disjoint, so this is the same test as the count comparison.
importCreates trims the title once and uses it for the project and heading bookkeeping as well as the create.
The lookups, notes and warnings move from closures in resolveImportDests to methods, the to-do and project cases become taskDest and projectDest, and the heading-id branch becomes headingIDDest.
@ryanlewis
ryanlewis merged commit 93c48fe into main Oct 10, 2026
8 checks passed
@ryanlewis
ryanlewis deleted the refactor/simplify branch October 10, 2026 00: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