Skip to content

chore: add golangci new-code quality gates - #30622

Merged
ibetitsmike merged 3 commits into
mike/golangci-anchor-gitfrom
mike/golangci-new-code-gates
Oct 13, 2026
Merged

ibetitsmike merged 3 commits into
mike/golangci-anchor-gitfrom
mike/golangci-new-code-gates

Conversation

@ibetitsmike

Copy link
Copy Markdown
Collaborator

Stack context: second layer of the Go lint gate stack, built on the exclusion fix below.

Why: adds commented-out code detection and a log/slog ban to the main config, plus a new-code-only pass requiring reasons on lint suppressions, flagging ignored errors (including _, _ = w.Write(...)), and banning time.Sleep in tests. Fixing the hits surfaced a real bug: GitLab warnings went to the wrong logger. The new-code pass resolves symlinked checkout paths so it does not silently report nothing.

Validation: both configs report 0 issues; each seeded violation is caught; make pre-commit passed.

Xum acted for Mike to open this PR.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T10:08:47.815903Z 2df37f3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Emyrk Emyrk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

InputPrice: nullInt64(999),
},
inputTokens: 1002, // 1002 * 999 = 1_000_998
inputTokens: 1002, // 1002 times 999 is 1_000_998.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

Enable gocritic commentedOutCode and a depguard rule that denies
log/slog in favor of cdr.dev/slog/v3, and fix the existing hits.

Delete commented-out code, reword comments that parse as Go, keep the
three log/slog imports that third-party APIs require behind explained
nolint directives, and route the GitLab provider's truncated-diff
warning through a cdr.dev/slog logger passed from externalauth.
…eep ban

Add .golangci.new-code.yaml and `make lint/go/new-code`, which only
report issues on lines changed since the merge base with
GO_LINT_NEW_CODE_BASE (default origin/main). The pass enables
nolintlint with require-explanation and require-specific, errcheck
with check-blank, and a forbidigo ban on time.Sleep in _test.go files.
The existing tree does not pass these rules, so they gate new code
only.

`make lint` (and so pre-commit and CI) runs the new target. Both
golangci-lint targets pass --allow-serial-runners so `make -j` waits
on the shared lock instead of failing. CI compares pull requests
against the merge commit's first parent and other events against
HEAD, which reports nothing.
golangci-lint matches --new-from-merge-base changed lines against
symlink-resolved file paths made relative to PWD. From a checkout
reached through a symlink no path matched, so the pass reported nothing
even for new violations. Resolve the working directory first.
@ibetitsmike
ibetitsmike force-pushed the mike/golangci-new-code-gates branch from 2df37f3 to cd4736e Compare October 13, 2026 07:30
@ibetitsmike
ibetitsmike merged commit 7517301 into main Oct 13, 2026
56 of 78 checks passed
@ibetitsmike
ibetitsmike deleted the mike/golangci-new-code-gates branch October 13, 2026 07:58
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants