Skip to content

clean code #149

@matt-beanland

Description

@matt-beanland

Backlog — Non-idiomatic Ash patterns
High
Silent error swallowing in reduce_while / {:halt, []}
Three files share the same anti-pattern: on failure they halt with an empty list [], discard the original error, and surface a generic string. The real error is gone.

lib/diffo/provider/components/instance/extension/relationship.ex — relate_instance/2
lib/diffo/provider/components/instance/extension/party.ex — party relating loop
lib/diffo/provider/components/instance/extension/place.ex — place relating loop
Ash way: propagate the actual error tuple; let Splode accumulate it.

Medium
Unreachable / dead code in IsRelatedDifferent
lib/diffo/validations/is_related_different.ex lines 29–31 — after the :error -> branch returns :ok, two further expressions ({:ok, nil} and a second :ok) are unreachable dead code left over from editing. Confusing to read, should be cleaned up.

Low
reduce_while for sequential side effects in build helpers
characteristic.ex and feature.ex use nested Enum.reduce_while for what is essentially a for-each-with-early-exit. Functional but hard to follow. Could be replaced with Enum.reduce_while → with chains or explicit recursion where error propagation is the real intent.

lib/diffo/provider/components/instance/extension/characteristic.ex
lib/diffo/provider/components/instance/extension/feature.ex
Biggest bang for buck is the three silent-halt files — they're the same mistake repeated and they destroy error information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactoringImproving existing code without changing functionality

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions