Sdlc/Structural/EffectInModel: fix wrong and missed effect records #1351

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

Problem

The recording cop Sdlc/Structural/EffectInModel records wrong effects and misses real ones in ledger model/value files.
It is loaded only by .rubocop-sweep.yml; it has 36 records in lib/.

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

Observed

Sample file:

module OsSdlc
  class RetiredTest
    def a(glob, path) = File.fnmatch?(glob, path)
    def b(path) = File.absolute_path?(path)
    def c(dir) = FileUtils.mkdir_p(dir)
    def d = Kernel.format("%d", 1)
    def e(p) = @path.read
    def f = ENV.fetch("HOME")
    def g = $stdout.puts("x")
    def h(p) = File.split(p)
  end
end

Wrong records: File.fnmatch? (a), File.absolute_path? (b), Kernel.format (d), File.split (h) are pure.
Missed record: FileUtils.mkdir_p (c) is a real effect.

Reproduce

n/a: matcher is plugins/os-sdlc/lib/os_sdlc/cops/effect_in_model/effect_call.rb; run the cop on the sample above with a model ledger role.

Approach

Fixes go in the cop matcher, never in a config Exclude list or a test-path exclusion.
Add fnmatch, fnmatch?, absolute_path, absolute_path?, and split to the pure File methods.
Record Kernel only for effect methods, not format, Integer, or Float.
Add FileUtils to the effect constants.

Required work:

  1. Add FileUtils and the pure File methods — check: present FileUtils in plugins/os-sdlc/lib/os_sdlc/cops/effect_in_model/effect_call.rb

Acceptance criteria

  1. Given File.fnmatch?(glob, path) in a model file, when the cop runs, then it records nothing.
  2. Given Kernel.format("%d", 1) in a model file, when the cop runs, then it records nothing.
  3. Given FileUtils.mkdir_p(dir) in a model file, when the cop runs, then it records an effect.

Origin

  • Trigger: #1325 zero-false-positive audit of the Sdlc cops
  • Improvised this session: none
  • Chain: wrong and missed records ← incomplete pure and effect lists ← DESIGN (plugins/os-sdlc/lib/os_sdlc/cops/effect_in_model/effect_call.rb)
  • Root candidate: none found; searched EffectInModel
  • Where: plugins/os-sdlc/lib/os_sdlc/cops/effect_in_model/effect_call.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 recording cop `Sdlc/Structural/EffectInModel` records wrong effects and misses real ones in ledger `model`/`value` files. It is loaded only by `.rubocop-sweep.yml`; it has 36 records in lib/. Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md). ## Observed Sample file: ```ruby module OsSdlc class RetiredTest def a(glob, path) = File.fnmatch?(glob, path) def b(path) = File.absolute_path?(path) def c(dir) = FileUtils.mkdir_p(dir) def d = Kernel.format("%d", 1) def e(p) = @path.read def f = ENV.fetch("HOME") def g = $stdout.puts("x") def h(p) = File.split(p) end end ``` Wrong records: `File.fnmatch?` (a), `File.absolute_path?` (b), `Kernel.format` (d), `File.split` (h) are pure. Missed record: `FileUtils.mkdir_p` (c) is a real effect. ## Reproduce n/a: matcher is `plugins/os-sdlc/lib/os_sdlc/cops/effect_in_model/effect_call.rb`; run the cop on the sample above with a `model` ledger role. ## Approach Fixes go in the cop matcher, never in a config Exclude list or a test-path exclusion. Add `fnmatch`, `fnmatch?`, `absolute_path`, `absolute_path?`, and `split` to the pure File methods. Record `Kernel` only for effect methods, not `format`, `Integer`, or `Float`. Add `FileUtils` to the effect constants. Required work: 1. Add `FileUtils` and the pure File methods — check: present `FileUtils` in `plugins/os-sdlc/lib/os_sdlc/cops/effect_in_model/effect_call.rb` ## Acceptance criteria 1. Given `File.fnmatch?(glob, path)` in a model file, when the cop runs, then it records nothing. 2. Given `Kernel.format("%d", 1)` in a model file, when the cop runs, then it records nothing. 3. Given `FileUtils.mkdir_p(dir)` in a model file, when the cop runs, then it records an effect. ## Origin - Trigger: #1325 zero-false-positive audit of the Sdlc cops - Improvised this session: none - Chain: wrong and missed records ← incomplete pure and effect lists ← DESIGN (plugins/os-sdlc/lib/os_sdlc/cops/effect_in_model/effect_call.rb) - Root candidate: none found; searched EffectInModel - Where: plugins/os-sdlc/lib/os_sdlc/cops/effect_in_model/effect_call.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#1351
No description provided.