Add a lint lesson for Naming/PredicateMethod #994
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#994
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
plugins/os-sdlc/lint-lessons/has no lesson forNaming/PredicateMethod. In n8n-api, 13 resource methods always returnedtrue. The cop flagged them, and a pipeline programmer turned the cop off for the whole directory (commit c51ebb3, jaredswanson/n8n-api#2). The cop message suggests a?rename, which was also wrong: these methods are commands, not questions. After #989 every lint path shows lessons, so a lesson for this cop reaches the next fixer. This is the pain point that started #989.def delete(id) … true enddelete?deleteis a commandNaming/PredicateMethod: Exclude: lib/n8n_api/resources/*.rbnilThe real fix, from
lib/n8n_api/resources/workflows.rbin 2c9d799:Reproduce
n/a: a lesson file is content.
Lesson::LibraryresolvesNaming/PredicateMethodtonaming-predicate-method.ymlwith no code change.Approach
Write
plugins/os-sdlc/lint-lessons/naming-predicate-method.ymlwith the same seven keys as the existing lessons (cop,signal,sign_of,why,decision,correction,example). The lesson teaches this decision:?trueon every pathnil; return data only when a caller needs it. Tests assert the request sent or the state changed, never the return valuetrueorfalsevariesRequired work:
cop: Naming/PredicateMethodinplugins/os-sdlc/lint-lessons/naming-predicate-method.ymlAcceptance criteria
Lesson::Libraryloads the lesson directory, then it returns a lesson forNaming/PredicateMethod.Naming/PredicateMethod, when any lint path renders its offense block, then the lesson text appears before the two smell questions.Owner sketch
The command test is the core of the lesson. The n8n-api fix (2c9d799) swapped
assert_equal trueforassert_nil, and that test still passes iftransfersends nothing. The lesson teaches the test to assert the effect (Metz, "The Magic Tricks of Testing": incoming command, assert the direct public side effect).deletereturning the record (2c9d799) is acceptable only when a caller uses the record.Origin
lint-lessons/holds custom-cop lessons only.DESIGN:plugins/os-sdlc/lint-lessons/.VERDICT: CREATE
REASON: Real observed pain (n8n-api c51ebb3 added a Naming/PredicateMethod Exclude with no human approval). It fits the user pain-point policy, no existing lesson covers the cop, and #989 already routes lessons to every lint path. The fix is one content file.
Resolution
Done: Added plugins/os-sdlc/lint-lessons/naming-predicate-method.yml (commit
0135e14c). The lesson teaches: query gets a ? name; command returns nil (data only when a caller needs it) and its tests assert the request or state change, never the return value; a state-dependent boolean is a false positive to report; never add an Exclude.Evidence: Lesson::Library.new(dir: lint-lessons).lesson('Naming/PredicateMethod') returns an OsSdlc::Lesson. OffenseAnalysis.default.guidance(['Naming/PredicateMethod']) renders the lesson before the two smell questions (order check true). library_test, offense_analysis_test, offense_paths_test, relay_lesson_files_test: 29 runs, 0 failures. bin/refresh-plugins synchronized os-sdlc.
Follow-ups: Dropped: the n8n-api tests from 2c9d799 assert only the return value (assert_nil), not the request sent. Offered to file on the n8n-api tracker; the user did not choose it this session.