refactor(lint): adopt new rubocop-go DSL across all cops#2687
Merged
dgageot merged 1 commit intodocker:mainfrom May 7, 2026
Merged
refactor(lint): adopt new rubocop-go DSL across all cops#2687dgageot merged 1 commit intodocker:mainfrom
dgageot merged 1 commit intodocker:mainfrom
Conversation
docker-agent
reviewed
May 7, 2026
docker-agent
left a comment
There was a problem hiding this comment.
Review: Lint Cop Refactor — rubocop-go DSL Adoption
Assessment: 🟢 APPROVE
This is a clean, well-structured refactor. All 12 cops were ported to the cop.Func literal style with correct Scope declarations, and the behavioral equivalence holds throughout. No regressions found.
Coverage summary:
| Area | Result |
|---|---|
versionFromImport regex → LastIndex replacement (configpath.go) |
✅ Equivalent — versionFromDir rejects non-vN suffixes identically |
ReportMissing called without empty-slice guard |
✅ Safe — library guards on len(names) == 0 internally |
returnedEventType unary-op check removed |
✅ Safe — *ast.UnaryExpr on a CompositeLit can only be & in valid Go |
WalkFuncWithContextScope replacing hand-rolled context analysis |
✅ Library handles body == nil guard; behavior matches |
cop.ParseTagOptions + HasName() replacing manual strings.Cut + "-" check |
✅ HasName() correctly rejects "" and "-" |
Declarative Scope fields vs. in-body guards |
✅ All scopes (paths, predicates, NotBlackBoxTest) faithfully match old guards |
p.PointerReceiverMethods replacing hand-rolled pointerReceiversWithMethod |
✅ Identical semantics per library source |
exportedBuiltinNames sort removed |
✅ ReportMissing sorts its input before joining — message still deterministic |
gtardif
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adopts the new
rubocop-goDSL across all 12 custom cops inlint/. Behaviour is unchanged — same offenses, same anchors, same severities — but the cops read better and a lot of plumbing moved into the library.What changed
cop.Funcliteral style everywhere. Each cop is now a single&cop.Func{Meta, Scope, Run}value. Thetype CopX struct { cop.Meta }+NewCopX()constructor +Checkmethod triplet is gone.Declarative scope. File-scope guards (
if !p.FileMatches(...) { return }) are gone fromCheckbodies; cops declare their scope as data and the runner skips out-of-scope files entirely:Library helpers absorbed boilerplate. Cops now use:
Pass.ReportMissing(anchor, fmt, names)— replaces the sort + join + empty-check pattern in 5 dispatch-table copsPass.PointerReceiverMethods(name),Pass.StructType(name),Pass.FirstMethodCall(name),Pass.FuncDecl(name)— direct lookups instead of hand-rolledForEach...filter loopscop.WalkFuncWithContextScope— the ~120 LOC of context-scope analysis fromslog_contextual.golifted into the librarycop.StringField,cop.ParseTagOptions,cop.FieldNames,cop.FieldTag,cop.IsNullaryFunc,cop.CallTo— small helpers for shapes that recurred across copsDropped the regex in
configpath.goin favour of a one-lineLastIndex+ delegation toversionFromDir, removing a drift point between the two helpers.main.go's registry is now a flatvar cops = []cop.Cop{...}of literal vars instead of a[]cop.Cop{NewX(), ...}builder.Numbers
lint/LOCValidation
task build,task test,task lint— all greenTUIViewPurity,SlogContextual(parameter-declared / nested funclit / discarded multi-return), andRuntimeSessionScoped— same offenses, same anchors, same wording as beforeNote for reviewers
The cops report 4 pre-existing offenses on current
main(inpkg/attachment/modelcaps/modelcaps.go,pkg/model/provider/anthropic/federation/federation.go,pkg/model/provider/openai/client.go). They exist onmainwith the original cops too — verified by checking out the pre-refactorlint/and re-running. They are realLint/SlogContextualviolations that landed during the time this branch was stale and are not introduced by this refactor; happy to fix in a separate PR.