Skip to content

chore: remove code that never runs or never changes a result - #13739

Closed
yuxi-liu-wired wants to merge 10 commits into
logseq:masterfrom
yuxi-liu-wired:fix/remove-unreachable-code
Closed

yuxi-liu-wired wants to merge 10 commits into
logseq:masterfrom
yuxi-liu-wired:fix/remove-unreachable-code

Conversation

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor

Removes code that never runs or never changes a result. Each removal is its own commit, with the reason in its message; behaviour is unchanged.

  • get-sql-rows (db-sync and publish copies): the (array? result) clause. Every JS array has Symbol.iterator, so the iterator clause before it always takes an array first.
  • search-fuzzy/score: a cond clause whose test repeats the clause before it.
  • worker get-all-properties: copying :logseq.property/deleted-at onto each result. Recycled properties (those with deleted-at) are removed first.
  • worker render-bottom-position-property?: node-many?. A :node property already passes (not= :default type) in the same or.
  • migrate ensure-built-in-data-exists!: the *uuids remap. It maps a uuid U to the uuid of the entity found by [:block/uuid U], which is U, so every lookup ref is rewritten to itself.
  • delete-blocks/build-retracted-tx: the unused 1-arity of this private fn.
  • frontend outliner.tree/blocks->vec-tree: the number and string root-id branches. Both callers pass a block uuid or nil.
  • outliner page/create: the convert-to-class branch. With class? the existing page is looked up among pages tagged Tag (or is a journal), so it is never a non-class internal page.
  • outliner build-property-value-tx-data: multiple-values-empty?. The block is an entity in every caller, and an entity's cardinality-many value is a set, never sequential.
  • apply-history-action!: the :unsupported-history-action branch after (seq ops'). ops' falls back to [[:transact ...]], so it is never empty.
  • logseq.db: *debounce-fn and register-debounce-fn!. The atom is read only inside a (comment ...) form.

Found by mutation testing (each was a surviving mutant: removing or changing it changed nothing any test could see), then checked against every caller on master.

Every JS array has Symbol.iterator, so the iterator clause above it
always takes an array first; the clause never runs.
Its test is the same as the clause above, so it is never chosen.
get-all-properties removes recycled properties (those with deleted-at)
first, so copying deleted-at onto the result never happens.
render-bottom-position-property?: a :node property already passes
(not= :default type), so node-many? adds nothing to the or.
…exists!

*uuids maps a uuid U to the uuid of the entity found by [:block/uuid U],
which is U, so the remap rewrites each lookup ref to itself.
The private fn's only caller passes both arguments.
…s->vec-tree

Both callers (editor handler, plugin API block tree) pass a block uuid
or nil.
With class? the existing page is looked up among pages tagged Tag
(page-exists? with #{:logseq.class/Tag}), or is a journal page, so it is
never a non-class internal page and the branch never runs.
…e-tx-data

block is an entity in every caller, and an entity's cardinality-many
value is a set, never sequential, so the check is always false.
ops' falls back to [[:transact ...]] when there are no semantic ops, so
(seq ops') is always true.
The atom is read only inside a (comment ...) form, so registering the
worker's debounced store has no effect.
@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Combined with the other PRs that change the same files into #13786.

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/remove-unreachable-code branch October 21, 2026 18:01
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