Sdlc/Sequel/DatasetResultCompared: carve out non-row terminals and non-Sequel _dataset names #1350

Open
opened 2026-10-25 21:22:20 +00:00 by jared · 0 comments
Owner

Problem

The cop Sdlc/Sequel/DatasetResultCompared flags a chain rooted at any *_dataset send that is compared or tested.
The matcher has no check for the root type, the terminal method, or the file location.
It flags code that is not a row decision.

Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md).

Observed

Counterexample 1: a SQL-string check is not a row decision.

class Order < Sequel::Model
  def sql_matches?(expected) = orders_dataset.sql == expected
  def same_rows?(other) = orders_dataset.all == other
end

Counterexample 2: a non-Sequel method named training_dataset is flagged.

class Training
  def ready?(sample_dataset) = training_dataset.size > 0
end

The lesson says "outside the owning model", but the matcher has no location check. The cop has 0 hits in plugins/.

Reproduce

n/a: matcher is plugins/os-sdlc/lib/os_sdlc/cops/dataset_result_compared.rb:15-25; run the cop on the samples above.

Approach

Carve-outs go in the cop matcher, never in a config Exclude list or a test-path exclusion.
Skip chains that end in sql, columns, or sql_literal.
Require the root to be an association dataset or Model.dataset known from the file, or skip when the file has no Sequel model.

Required work:

  1. Add the non-row terminal carve-out — check: present sql_literal in plugins/os-sdlc/lib/os_sdlc/cops/dataset_result_compared.rb

Acceptance criteria

  1. Given orders_dataset.sql == expected, when the cop runs, then it reports no offense.
  2. Given a file with no Sequel model and training_dataset.size > 0, when the cop runs, then it reports no offense.
  3. Given orders_dataset.all == other in a Sequel model, when the cop runs, then it still reports an offense.

Origin

  • Trigger: #1325 zero-false-positive audit of the Sdlc cops
  • Improvised this session: none
  • Chain: false positive ← name-only root and no terminal filter ← DESIGN (plugins/os-sdlc/lib/os_sdlc/cops/dataset_result_compared.rb)
  • Root candidate: none found; searched DatasetResultCompared
  • Where: plugins/os-sdlc/lib/os_sdlc/cops/dataset_result_compared.rb
  • Session: eb98cdcd-6783-46a0-b7df-cf18a8fe2a56
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-ticket-1325/eb98cdcd-6783-46a0-b7df-cf18a8fe2a56.jsonl
    VERDICT: CREATE
## Problem The cop `Sdlc/Sequel/DatasetResultCompared` flags a chain rooted at any `*_dataset` send that is compared or tested. The matcher has no check for the root type, the terminal method, or the file location. It flags code that is not a row decision. Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md). ## Observed Counterexample 1: a SQL-string check is not a row decision. ```ruby class Order < Sequel::Model def sql_matches?(expected) = orders_dataset.sql == expected def same_rows?(other) = orders_dataset.all == other end ``` Counterexample 2: a non-Sequel method named `training_dataset` is flagged. ```ruby class Training def ready?(sample_dataset) = training_dataset.size > 0 end ``` The lesson says "outside the owning model", but the matcher has no location check. The cop has 0 hits in plugins/. ## Reproduce n/a: matcher is `plugins/os-sdlc/lib/os_sdlc/cops/dataset_result_compared.rb:15-25`; run the cop on the samples above. ## Approach Carve-outs go in the cop matcher, never in a config Exclude list or a test-path exclusion. Skip chains that end in `sql`, `columns`, or `sql_literal`. Require the root to be an association dataset or `Model.dataset` known from the file, or skip when the file has no Sequel model. Required work: 1. Add the non-row terminal carve-out — check: present `sql_literal` in `plugins/os-sdlc/lib/os_sdlc/cops/dataset_result_compared.rb` ## Acceptance criteria 1. Given `orders_dataset.sql == expected`, when the cop runs, then it reports no offense. 2. Given a file with no Sequel model and `training_dataset.size > 0`, when the cop runs, then it reports no offense. 3. Given `orders_dataset.all == other` in a Sequel model, when the cop runs, then it still reports an offense. ## Origin - Trigger: #1325 zero-false-positive audit of the Sdlc cops - Improvised this session: none - Chain: false positive ← name-only root and no terminal filter ← DESIGN (plugins/os-sdlc/lib/os_sdlc/cops/dataset_result_compared.rb) - Root candidate: none found; searched DatasetResultCompared - Where: plugins/os-sdlc/lib/os_sdlc/cops/dataset_result_compared.rb - Session: eb98cdcd-6783-46a0-b7df-cf18a8fe2a56 - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-ticket-1325/eb98cdcd-6783-46a0-b7df-cf18a8fe2a56.jsonl VERDICT: CREATE
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#1350
No description provided.