Skip to content

grooming: dead and duplicated code after the native desktop move #213

Closed

Description

@frostyard-machines

Dead and duplicated code found in a grooming pass of main at b9c6c90. Each item keeps behavior when removed or merged; together they are more than 1 small grooming PR, so they are listed here for later passes.

Exported, but only tests call it (checked with grep -rn over cmd/, internal/, api/ and app/src/):

  • internal/store/search.go:51-86 (*DB).Search: the same SQL as SearchNotes with only a match; note.search uses SearchNotes (internal/engine/note.go:123). search_test.go is its only caller.
  • internal/store/vault.go:76-88 (*DB).GetVault (vault_test.go only).
  • internal/vault/move.go:266-274 retargetText (move_test.go only; rewriteLinks uses targetSpan).
  • internal/blobxfer/client.go:121-125 (*Client).DownloadAll (client_test.go only).
  • internal/store/changes.go:55-62 (*DB).PruneChanges (store_test.go only). So the changes log is never pruned, and the broker's resync branch for a sequence older than the log (internal/events/broker.go:87-95) never triggers. That is the documented state today (notesd keeps the whole log); whether to keep the function for a later retention step or remove it is the owner's call.
  • app/src/app/narrow.ts:8-9 NARROW: only narrow.test.tsx imports it; the app uses useNarrow.

Duplicates:

  • internal/blobs/blobs.go:70-104 Put and :111-146 PutWant: the same temp file, hash, sync and publish steps; only the ID check differs.
  • internal/store/queries.go:88-99 and internal/store/search.go:203-207: the same nested-tag EXISTS clause (tags.folded = ? OR (tags.folded >= ? AND tags.folded < ?)).
  • internal/vault/backlinks.go:75-77 valid and internal/vault/write.go:74 showText: the same function in 1 package.
  • internal/syncer/loop.go:1314-1317 ignored and internal/syncer/service.go:430-433 vaultPathHeld: 1 lookup and its negation; vault.Author{Source: api.VersionSourceSync, Name: "sync"} is written out 5 times in loop.go.
  • cmd/notesctl/: if written, err := clix.OutputJSON(x); err != nil || written { return err } in 23 places.
  • app/src/app/MainWindow.tsx:190-210 and :248-266: the side pane's PaneTabs, Pane and VaultRow block, once for the wide layout and once for the drawer.
  • app/src/app/menus.ts:34-40 and app/src/app/panes/files.tsx:214-219: the same item() menu helper.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions