Mechanical cleanup, quick fixes & deduplication #531

Closed
opened 2026-06-15 22:07:53 +02:00 by moritz · 0 comments
Owner

Motivation

A batch of small, low-risk fixes and dedup.
Bundled into one issue with a single theme: no behavior change (except fixing two latent bugs), and clear out
duplication and dead code. This also unblocks a Credo ratchet (see Acceptance).

Scope

Quick fixes / latent bugs

  • Fix the AshAuthentication supervisor otp_app: :my:mv in lib/mv/application.ex:35. Verified bug: the
    app is :mv, so the Expunger/audit-log batcher children resolve config under the wrong OTP app and run against
    empty config in non-test environments. After the fix, confirm all auth children boot.
  • Delete the orphaned lib/accounts/user_identity.exs (verified: zero references, no migration / user_identities
    table, OIDC stores identity on User via oidc_id, the oidc strategy sets no identity_resource).
  • Delete the dead MemberExport.fetch/2 chain in lib/mv/membership/member_export.ex:53-274 (~220 LOC; confirm
    zero callers across lib + test first).
  • Drop the unconditional per-render Logger.info timing on the member-list hot path
    (lib/mv_web/live/member_live/index.ex:1029-1030).

Deduplication (behavior-preserving)

  • Dropdown keyboard-nav handlers duplicated between user_live/form.ex:574-624 and group_live/show.ex:568-613.
  • Fee-type handling blocks duplicated between membership_fee_type_live/index.ex:147-196 and
    membership_fee_settings_live.ex.
  • current_actor(conn) copy-pasted across member_pdf_export_controller.ex:84, member_export_controller.ex:56,
    import_template_controller.ex:108 → one shared helper.
  • Calendar.strftime(date, "%d.%m.%Y") reimplemented in membership_fee_helpers.ex:253 and
    member_live/show.ex:725,763 → use MvWeb.Helpers.DateFormatter.format_date/1.
  • Identical send/build skeleton across the three join-email modules → shared skeleton.
  • Two near-identical own_data policy checks (membership_fee_cycle_read_linked_for_own_data.ex,
    member_group_read_linked_for_own_data.ex) → one generic check.
  • JSONB single-field update scaffolding duplicated between UpdateSingleMemberField and
    UpdateSingleMemberFieldVisibility (update_single_member_field.ex:153-178).
  • Fold run/0run/1 in cycle_generation_job.ex:62.
  • Delete the OidcRoleSyncConfig passthrough wrapper + its delegation-only test, and the duplicate
    TypeParsers.parse_boolean.
  • Dedup load_linked_member (sync_linked_member_after_user_change.ex:59) against Mv.EmailSync.Loader.
  • Correct the overstated reject_join_request @spec (membership.ex:839-851).

Module-layout normalization

  • Reorder module elements in the 58 files flagged by Readability.StrictModuleLayout (mechanical).

Acceptance criteria

  • All listed fixes/dedup done; no dead code or unused aliases remain.
  • Existing tests stay green (no behavior change other than the otp_app fix); add a small test that the auth
    children boot with the corrected otp_app.
  • The 58 StrictModuleLayout violations are cleared; promote Readability.StrictModuleLayout into the gate
    .credo.exs (ratchet). (Warning.UnsafeToAtom is promoted in issue "Correctness …", where its fix lands.)
  • just ci-dev green.
## Motivation A batch of small, low-risk fixes and dedup. Bundled into one issue with a single theme: no behavior change (except fixing two latent bugs), and clear out duplication and dead code. This also unblocks a Credo ratchet (see Acceptance). ## Scope **Quick fixes / latent bugs** - Fix the AshAuthentication supervisor `otp_app: :my` → `:mv` in `lib/mv/application.ex:35`. Verified bug: the app is `:mv`, so the Expunger/audit-log batcher children resolve config under the wrong OTP app and run against empty config in non-test environments. After the fix, confirm all auth children boot. - Delete the orphaned `lib/accounts/user_identity.exs` (verified: zero references, no migration / `user_identities` table, OIDC stores identity on `User` via `oidc_id`, the oidc strategy sets no `identity_resource`). - Delete the dead `MemberExport.fetch/2` chain in `lib/mv/membership/member_export.ex:53-274` (~220 LOC; confirm zero callers across lib + test first). - Drop the unconditional per-render `Logger.info` timing on the member-list hot path (`lib/mv_web/live/member_live/index.ex:1029-1030`). **Deduplication (behavior-preserving)** - Dropdown keyboard-nav handlers duplicated between `user_live/form.ex:574-624` and `group_live/show.ex:568-613`. - Fee-type handling blocks duplicated between `membership_fee_type_live/index.ex:147-196` and `membership_fee_settings_live.ex`. - `current_actor(conn)` copy-pasted across `member_pdf_export_controller.ex:84`, `member_export_controller.ex:56`, `import_template_controller.ex:108` → one shared helper. - `Calendar.strftime(date, "%d.%m.%Y")` reimplemented in `membership_fee_helpers.ex:253` and `member_live/show.ex:725,763` → use `MvWeb.Helpers.DateFormatter.format_date/1`. - Identical send/build skeleton across the three join-email modules → shared skeleton. - Two near-identical own_data policy checks (`membership_fee_cycle_read_linked_for_own_data.ex`, `member_group_read_linked_for_own_data.ex`) → one generic check. - JSONB single-field update scaffolding duplicated between `UpdateSingleMemberField` and `UpdateSingleMemberFieldVisibility` (`update_single_member_field.ex:153-178`). - Fold `run/0` → `run/1` in `cycle_generation_job.ex:62`. - Delete the `OidcRoleSyncConfig` passthrough wrapper + its delegation-only test, and the duplicate `TypeParsers.parse_boolean`. - Dedup `load_linked_member` (`sync_linked_member_after_user_change.ex:59`) against `Mv.EmailSync.Loader`. - Correct the overstated `reject_join_request` @spec (`membership.ex:839-851`). **Module-layout normalization** - Reorder module elements in the 58 files flagged by `Readability.StrictModuleLayout` (mechanical). ## Acceptance criteria - All listed fixes/dedup done; no dead code or unused aliases remain. - Existing tests stay green (no behavior change other than the `otp_app` fix); add a small test that the auth children boot with the corrected `otp_app`. - The 58 `StrictModuleLayout` violations are cleared; promote `Readability.StrictModuleLayout` into the gate `.credo.exs` (ratchet). (`Warning.UnsafeToAtom` is promoted in issue "Correctness …", where its fix lands.) - `just ci-dev` green.
moritz added this to the Code and Test Refactoring | TI I milestone 2026-06-15 22:07:53 +02:00
moritz added this to the Sprint 18: Juli 2026 project 2026-06-15 22:07:59 +02:00
moritz modified the project from Sprint 18: Juli 2026 to Sprint 17: Juni 2026 2026-06-15 22:33:48 +02:00
moritz self-assigned this 2026-06-15 22:34:01 +02:00
Sign in to join this conversation.
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: local-it/mitgliederverwaltung#531
No description provided.