Skip to content

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

Closed

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.


Resolution

Status: Already fixed by #1476 (35fe54c8); re-measured 2026-10-07: 240 executions under the full suite, x && !y = 2 vs x && -y = 1. See the closing comment.

Activity

  1. dekobon commented on Oct 8, 2026

    @dekobon
    OwnerAuthor

    Re-measured on main (c5a847d) — no longer reproduces

    elixir_inspect_container is executed. cargo llvm-cov --no-report nextest --all-features --workspace (5,781 tests) records 240 entries into the function (src/metrics/abc/elixir.rs:33); the peel body runs 155 times and the terminal-count line (*conditions += 1.) 150 times.

    Behaviourally, bca metrics --no-config against an identifier control at the same cyclomatic:

    Elixir abc.conditions
    x && !y 2
    x && -y (control: not a negation) 1
    x and not y 2
    x && (y) 2
    x && !(y) 2
    guards when not is_nil(y), when (y), when not y 1 each

    Why the issue saw 0 hits: it was filed 2026-09-15T03:28Z, and 35fe54c8 (#1476, merged later the same day) rewrote this function. That commit added not alongside ! and the when guard slot, which calls it through elixir_count_condition, and it added elixir_keyword_not_negates_like_bang. The line quoted in the body (== E::BANG only) is the pre-#1476 code. At filing time the function was untested rather than unreachable, and #1476 then covered it.

    One residual uncovered line: line 64, has_boolean_content = true;. It is only reachable with a non-binary_operator parent, and both current callers always pass a binary_operator (the &&/|| chain node, or the guard's owner). It is a defensive branch, not a missed condition.

    Closing as resolved by #1476. Verified during the 2026-10-07 ABC batch.

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