Repository navigation
feat(route): guide golangci-lint through forbidigo and depguard - #722
Conversation
detect has recognized golangci-lint since v0.10.0, but route named it only as a tool with no guide of its own, so an agent in a Go repository had to work out golangci-lint's catch-alls and its v1/v2 config layout by hand. Add a create-legacy-rule recipe and a route paragraph for it, and pin detection for each config spelling and for v1 and v2 configs.
|
@claude /review |
|
Claude finished @aibex-agent[bot]'s task in 2m 11s —— View job Review completeReview mode: incremental — read 0 prior review thread(s) before reviewing. The
FindingsOne [New] low-severity nit, posted inline on What I checked and why I found it sound
Not independently verified (no network access, consistent with the PR's own "not run against a real golangci-lint binary" caveat): the real-world accuracy of |
| - `forbidigo`: bans identifiers matched by a regular expression, each | ||
| with its own message, through `forbid` entries of `pattern` and | ||
| `msg`. With `analyze-types: true`, a `pkg` pattern matches the | ||
| import path, so `^v1.Dump$` can mean one package's `Dump` and not |
There was a problem hiding this comment.
[New] Minor doc nit: ^v1.Dump$ has an unescaped ., which as a regex matches any character, not just a literal dot (so it would also match e.g. v1xDump). The same recipe correctly escapes the dot elsewhere (^fmt\.Print.*$ at line 66), and this paragraph's own point is precision ("one package's Dump and not another's"), so the unescaped example undercuts itself if an agent copies it literally into a real forbidigo pattern.
| import path, so `^v1.Dump$` can mean one package's `Dump` and not | |
| import path, so `^v1\.Dump$` can mean one package's `Dump` and not |
#712 reports that
detect --jsonfound no linter in a Go repository with a golangci-lint v2 config, so the legacy ladder was skipped and had to be re-derived by hand.The detection half does not reproduce.
LINTER_SIGNALShas carried agolangci-lintentry (all four config spellings, thego.modtool/requiredependency, thegolangci-lintinvocation) since v0.10.0. Built from both v0.13.7 and HEAD,detect --jsonon the issue's exact repository (go.modplus the.golangci.ymlwithversion: "2",forbidigo,gosec) reportsgolangci-lintwith evidence.golangci.yml. It also holds for a nested module and for a scan root under a directory namedbuild,binorvendor.countCustomRulesalready falls through todefaultfor it, as the issue asks.The ladder half does reproduce.
routenamed golangci-lint only on its "also detected, with no guide of their own" line and sent the agent to the genericcreate-legacy-rulerecipe, which names catch-alls for ESLint, Ruff, Biome and pylint and none for Go. That is the "re-derived by hand" in the report.Changes
create-legacy-rule.golangci-lint.md: checkforbidigoanddepguardfirst; find a bundled linter withgolangci-lint help linters; confirm withgolangci-lint linters; write settings in the config's own version (linters.settingsfor v2,linters-settingsfor v1) without migrating it; verify withgolangci-lint config verify.detectcounts no golangci-lint custom rules, so it never authors aruleguardrule or module plugin.route's per-linter passage..golangci.{yml,yaml,toml,json}, from the issue's v2 config and its v1 form (with no custom-rule count), and no linter for a Go repo without a config; therouteparagraph; the recipe's catch-all order and v1/v2 keys.golangci-lint-legacy-recipe, archived: MODIFIED deltas tocli-legacy-rule-recipesandcli-rule-routing, restated in full. Checked that every prior scenario survives the archive.patchchangeset.The recipe's claims were checked against golangci-lint's documentation (configuration file, CLI, linter settings, migration guide). Two corrected assumptions:
forbidigohas a default pattern list, anddepguardwith no rules allows only the standard library, so the recipe says neither is a no-op when unconfigured. Not run against a real golangci-lint binary; there is no vendor-contract test for it like the Python and JS linters have.pnpm typecheck,pnpm lint, and the CLI suite (3426 tests) pass locally.Fixes #712