Sdlc/Sequel/InlineDatasetQuery: prove the receiver is a Sequel dataset #1362

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

Problem

Sdlc/Sequel/InlineDatasetQuery decides by the method-name suffix /_dataset\z/ alone.
The suffix does not prove a Sequel dataset.
Shape: a send of where/filter/exclude/or/order/limit/offset/group/having whose receiver chain starts at any *_dataset method outside a dataset_module block.

Observed

The cop fires on an Array. Sample code:

class Trainer
  def training_dataset
    File.readlines("rows.txt")
  end

  def valid_rows
    training_dataset.filter { |row| row.start_with?("ok") }
  end
end

training_dataset.filter fires, but there is no model to move the query to.
Real repo hit: plugins/os-sdlc/tests/dispatch_test.rb:211 (newest.limit(1)). limit/offset after an already named scope arguably owns no row rule.

Reproduce

Run the cop on the sample above.

Approach

Required work:

  1. Match only *_dataset names that are Sequel association dataset methods (an association declared on a model in the codebase) or Model.dataset/Model.where chains.
  2. Decide whether limit/offset after a named scope is a row rule (dispatch_test.rb:211).

Carve-outs go in the cop matcher. Do not add config Exclude lists or test-path exclusions.

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

Origin

  • Trigger: #1325 zero-false-positive audit of the Sdlc cops
  • Improvised this session: none
  • Chain: false positive on valid code ← cop matcher tests a proxy shape, not the real condition ← DESIGN (cop source named in Where:)
  • Root candidate: none found; searched the cop name, its mechanism terms, and false positive. Related, not the same fault: #917 (same cop, test-path scope)
  • Where: plugins/os-sdlc/lib/os_sdlc/cops/inline_dataset_query.rb:13-25
  • 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 Sdlc/Sequel/InlineDatasetQuery decides by the method-name suffix `/_dataset\z/` alone. The suffix does not prove a Sequel dataset. Shape: a send of where/filter/exclude/or/order/limit/offset/group/having whose receiver chain starts at any `*_dataset` method outside a `dataset_module` block. ## Observed The cop fires on an Array. Sample code: ```ruby class Trainer def training_dataset File.readlines("rows.txt") end def valid_rows training_dataset.filter { |row| row.start_with?("ok") } end end ``` `training_dataset.filter` fires, but there is no model to move the query to. Real repo hit: plugins/os-sdlc/tests/dispatch_test.rb:211 (`newest.limit(1)`). `limit`/`offset` after an already named scope arguably owns no row rule. ## Reproduce Run the cop on the sample above. ## Approach Required work: 1. Match only `*_dataset` names that are Sequel association dataset methods (an association declared on a model in the codebase) or `Model.dataset`/`Model.where` chains. 2. Decide whether `limit`/`offset` after a named scope is a row rule (dispatch_test.rb:211). Carve-outs go in the cop matcher. Do not add config Exclude lists or test-path exclusions. Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md) ## Origin - Trigger: #1325 zero-false-positive audit of the Sdlc cops - Improvised this session: none - Chain: false positive on valid code ← cop matcher tests a proxy shape, not the real condition ← DESIGN (cop source named in Where:) - Root candidate: none found; searched the cop name, its mechanism terms, and false positive. Related, not the same fault: #917 (same cop, test-path scope) - Where: plugins/os-sdlc/lib/os_sdlc/cops/inline_dataset_query.rb:13-25 - 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#1362
No description provided.