lint rule: tautological-assertion (equality between same-subject calls) #204

Closed
opened 2026-08-01 14:16:54 +00:00 by jared · 1 comment
Owner

Migrated from jared/os-sdlc#29 (repo retired).

Problem

first = Subject.new(same_args).call
second = Subject.new(same_args).call
assert_equal first, second

Both operands are calls to the same subject with no independently-known expected value -- an implementation that always returns a constant would pass.

Detection

  • Inputs: *_test.rb files.
  • Algorithm: flag assert_equal(a, b) calls whose two operands are both calls to the same method on instances of the same freshly-constructed subject, with no literal/expected-value operand.
  • Failure message: "asserts equality between two calls to the same subject -- no explicit expected value, so a constant-returning implementation passes. Assert the known expected value instead."

Correction

Assert the known expected value (compute/document it), rather than comparing two live calls to the same subject.

Pass/fail examples

  • Must fail: assert_equal first, second where both are Subject.new(same_args).call.
  • Must pass: assert_equal "expected_value", subject.call against a documented expected value.

Provenance

Codex finding. Run 18 (ticket #18, decision-dice sandbox, now retired), dual review, 2026-07-21.

Implementation plan

Candidate custom cop for plugins/os-sdlc/lib/os_sdlc/cops/ (Sdlc/Minitest namespace).

Migrated from jared/os-sdlc#29 (repo retired). ## Problem first = Subject.new(same_args).call second = Subject.new(same_args).call assert_equal first, second Both operands are calls to the same subject with no independently-known expected value -- an implementation that always returns a constant would pass. ## Detection - **Inputs:** *_test.rb files. - **Algorithm:** flag assert_equal(a, b) calls whose two operands are both calls to the same method on instances of the same freshly-constructed subject, with no literal/expected-value operand. - **Failure message:** "asserts equality between two calls to the same subject -- no explicit expected value, so a constant-returning implementation passes. Assert the known expected value instead." ## Correction Assert the known expected value (compute/document it), rather than comparing two live calls to the same subject. ## Pass/fail examples - **Must fail:** `assert_equal first, second` where both are `Subject.new(same_args).call`. - **Must pass:** `assert_equal "expected_value", subject.call` against a documented expected value. ## Provenance Codex finding. Run 18 (ticket #18, decision-dice sandbox, now retired), dual review, 2026-07-21. ## Implementation plan Candidate custom cop for plugins/os-sdlc/lib/os_sdlc/cops/ (Sdlc/Minitest namespace).
Author
Owner

Implemented as Sdlc/Minitest/TautologicalAssertion (commit 4479a50, branch worktree-sdlc-lint-cops). 6 tests green, rubocop clean.

Implemented as Sdlc/Minitest/TautologicalAssertion (commit 4479a50, branch worktree-sdlc-lint-cops). 6 tests green, rubocop clean.
jared closed this issue 2026-08-01 14:33:20 +00:00
Sign in to join this conversation.
No milestone
No project
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
jared/cc-os#204
No description provided.