Skip to content

fix(abc/elixir): elixir_inspect_container is never executed #1468

Description

@dekobon

Summary

src/metrics/abc/elixir.rs's elixir_inspect_container — the whole peel
loop, roughly lines 49–75 — is never executed. cargo llvm-cov over the
full suite (5,766 tests, --all-features --workspace) records 0 hits on
every line of it, and the file sits at 78.34% region coverage against a
95.61% project figure, almost entirely because of this block.

Evidence

   49|      0|            && node.child(0).is_some_and(|c| c.kind_id() == E::BANG as u16);
   54|      0|        if !has_boolean_content && is_not {
   61|      0|        let next = if is_not {
   66|      0|        let Some(child) = next else { break };
   70|      0|        if matches!(node_kind, elixir_bool_terminal_kinds!()) {
   72|      0|                *conditions += 1.;

This is pre-existing, not introduced by the 2026-09-14 batch:
elixir_inspect_container is on main at line 32 and that batch's hunks
land at lines 10, 108, 191 and 225.

Why it matters

Dead code in a condition-classification path is one of two things, and they
need different fixes:

  1. Unreachable — no caller routes an Elixir wrapper here, so an Elixir
    if (!x) / if ((x)) predicate silently scores nothing. That is a live
    metric defect of the class fix(metrics): six ABC and cyclomatic fixes #1459 / fix(abc/groovy): indexing and safe navigation score no condition #1466 / fix(abc/csharp): the null-forgiving b! scores no condition #1463 each fixed in another
    language.
  2. Merely untested — reachable but no fixture exercises it, in which
    case it is an untested branch in a metric everyone gates on.

Sibling languages route these through a <lang>_wrapper_operand peel that
their <lang>_count_condition queries. Elixir's equivalent appears not to
be wired to anything.

Suggested first step

Determine which of the two it is before planning a fix: enumerate callers of
elixir_inspect_container, then measure if (!x) / if ((x)) /
if (!(x)) in Elixir against a bare identifier control at the same
cyclomatic, per the measurement discipline in #1458.

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions