Skip to content

refactor: duplicated store and session code #53

Description

@ewanc26

I want no duplicated code in Indigo. A clone scan (jscpd --min-tokens 80 --min-lines 12 over src/) finds six clones: 42 lines inside src/atproto/session.c, 26 between src/store/session_store.c and settings_store.c, 15 between draft_store.c and session_store.c (the read-a-small-file and write-it-atomically shape three times), 23 inside src/app/app.c (the list-screen update handlers), and 15 in tools/snapshot.c.

What I want: one small-file store helper (read, write atomically, bounds) that the three stores use, the session job functions folded onto one request/result pattern, and the list screens' update handlers sharing one function. One PR each, host tests green, no behaviour change.

Also from cppcheck --enable=unusedFunction (after #52 removed the one with no callers): indigo_media_known, indigo_layout_hit and indigo_settings_store_clear are called only by the tests; each should be a real API or go.

Written by Claude on my behalf.

Activity

  1. added
    refactorRestructuring with no change in behaviour
    area: storagePersistence: databases, files and saved state
    duplicationLogic copied between repos that belongs in Wolfram
    on Oct 7, 2026
  2. ewanc26 commented on Oct 7, 2026

    @ewanc26
    OwnerAuthor

    Progress: duplicated lines in src went from 1.53% to 0.80% (#60), and session.c, app.c and layout.c are split into smaller files (#61, #62, #64). What is left is small (the do_* job wrappers in session_people.c and session_lists.c still repeat their fetch-fill-publish shape). Leaving this open for that.

  3. ewanc26 commented on Oct 8, 2026

    @ewanc26
    OwnerAuthor

    Fixed in v0.12.1: session-agent guard macro (INDIGO_SESSION_AGENT_GUARD) applied; session_people.c / session_lists.c verified.

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

    area: storagePersistence: databases, files and saved stateduplicationLogic copied between repos that belongs in WolframrefactorRestructuring with no change in behaviour

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions