Sdlc/Structural/UnreadInstanceVariable: skip base-class ivars that subclasses read and fix the prescription #1377
Labels
No labels
P0
P1
P2
P3
bug
category/code-change
category/cross-repo
category/eval-run
category/investigation
category/no-test-target
category/owner-ruling
category/prose-artifact
category/recurring-chore
category/structure
category/umbrella
crc-refactor
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
rule-proposal
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#1377
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Sdlc/Structural/UnreadInstanceVariableflags an ivar in a base class that a subclass reads. The existing subclass skip (:18) does not cover the superclass. The message also prescribes "delete the assignment and its parameter", which breaks code when something else reads the parameter.Observed
Shape: a RecordingCop subclass (
unread_instance_variable.rb:14) whose message prescribes a fix. For a class without a superclass, or a module, whose body assigns an ivar that no read,attr_reader, or delegator names (unread_assignments.rb). Registered at.rubocop.yml:385. It reports 9 hits.Counterexamples:
plugins/os-me/lib/os_me/lever_check.rb:10(read inlever_check/source.rb:12).plugins/os-vault/eval/bin/check:298(read at:312).plugins/os-aidd-lint/lib/aidd_lint/tier2/judge.rb:15.@configis unread, but the parameterconfigis read at:17, so deleting the parameter breaks the method.Sample code:
Reproduce
Approach
Fix by shape, in the cop matcher. Skip a class with no superclass when the codebase has a subclass that reads the ivar, or record without a fix. Change the message to "delete the parameter only if nothing else reads it". Do not add a config Exclude list or a test-path exclusion.
Required work:
only if nothing else reads itinplugins/os-sdlc/lib/os_sdlc/cops/unread_instance_variable.rbAcceptance criteria
@clientand a subclass in the same file that reads@client, when the cop runs, then it reports no offense.Owner sketch
Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md).
VERDICT: CREATE
Origin
unread_instance_variable.rb:18)