Update golangci-lint to v2.12.2 with canonical config #17
Reference in New Issue
Block a user
Delete Branch "golangci-v2.12.2"
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?
Adds the canonical
.golangci.yml(v2 schema,default: allwith a small documented disable list) and pins theDockerfilelint stage togolangci/golangci-lint:v2.12.2by tag and digest, replacing the previous v1.64.8 digest-only pin. TheMakefileinvokesgolangci-lintunversioned and CI builds via Docker, so no other pins existed.The v1 to v2 jump surfaced 74 findings; all are fixed with no changes to exported signatures or runtime behavior:
_(revive, 38)nlreturn8,wsl_v54,whitespace1,embeddedstructfieldcheck1)%winstead of%v(err113, 2)errcheck2,errchkjson1)http.NewRequestWithContext+http.DefaultClient.Doinstead ofhttp.Post, propagating the handler context (noctx)fmt.Fprintln(os.Stdout, ...)instead offmt.Println(forbidigo)mnd, 2)slog.LevelDebugcase, same white color as before (exhaustive)interface{}toany(modernize)package simplelog_testwitht.Parallel()(testpackage2,paralleltest1)funcorder,lll)Three
//nolintdirectives with justifications cover the package's intentional design:gochecknoinits/gochecknoglobalsfor the install-on-import default logger, andireturnforNewExtendedEventreturning the exportedExtendedEventinterface.make check(fmt-check, lint, test) is green.TODO.mdCompleted Steps updated in the same commit.Noted while in here, not touched: golangci-lint warns that
gomodguardis deprecated since v2.12.0 in favor ofgomodguard_v2(config is canonical and shared, so left as is), and theDockerfiletest stage still pinsgolang1.22.12 from 2025-02.Add the canonical .golangci.yml (v2 schema, all linters enabled with a small documented disable list) and pin the Dockerfile lint stage to golangci/golangci-lint:v2.12.2 by tag and digest, replacing the old v1.64.8 digest-only pin. Fix all findings surfaced by the v1 to v2 jump without changing any exported signatures or behavior: - add package and exported-symbol doc comments (revive) - rename unused handler parameters to underscore (revive) - check or explicitly discard error returns (errcheck, errchkjson) - wrap errors with %w instead of %v (err113) - use http.NewRequestWithContext instead of http.Post (noctx) - replace fmt.Println with fmt.Fprintln(os.Stdout, ...) (forbidigo) - name magic numbers as constants (mnd) - add explicit slog.LevelDebug case (exhaustive) - interface{} to any (modernize) - move tests to the simplelog_test package (testpackage) and add t.Parallel() (paralleltest) - move NewWebhookHandler above its methods (funcorder) - whitespace, line-length, and blank-line fixes (wsl_v5, whitespace, nlreturn, lll, embeddedstructfieldcheck) - nolint with justification for the intentional init/global design (gochecknoinits, gochecknoglobals) and interface-returning constructor (ireturn)View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.