Skip to content

chore: update golangci-lint config#3306

Merged
BradLugo merged 2 commits into
masterfrom
blugo/update-golangci-lint-config
Jun 26, 2026
Merged

chore: update golangci-lint config#3306
BradLugo merged 2 commits into
masterfrom
blugo/update-golangci-lint-config

Conversation

@BradLugo

Copy link
Copy Markdown
Contributor

@BradLugo BradLugo requested a review from a team as a code owner June 26, 2026 07:44
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 65039770-d9f6-4fd0-a3ff-5928b5fbdf94

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The .golangci.yml configuration is converted to the version 2 layout, with revised linter enablement, exclusions, issue limits, and formatter settings.

Changes

golangci-lint configuration rewrite

Layer / File(s) Summary
Schema and enabled linters
.golangci.yml
Adds version: "2", updates output configuration, and moves linter selection into an explicit linters block with relocated govet and gosec settings.
Exclusions, limits, and formatters
.golangci.yml
Updates nolintlint, revive, and staticcheck settings, adds linters.exclusions, sets issue caps to zero, and enables gofmt and goimports under formatters.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: updating the golangci-lint configuration.
Description check ✅ Passed The description is directly related to the config update and its motivation, OOM failures in GitHub Actions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch blugo/update-golangci-lint-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.golangci.yml:
- Line 3: The golangci-lint config and toolchain are mismatched, and the
exclusion patterns using trailing $ are not excluding directory contents. Update
the paths exclusions in the golangci-lint config to use directory-prefix entries
for third_party, builtin, and examples, and migrate the lint tool installation
to the /v2 module path in both the Makefile and tools/linters/go.mod. Keep the
version: "2" config aligned with the v2 golangci-lint module and verify the
updated exclusions still apply through the existing golangci-lint settings.
- Around line 113-116: The exclusion patterns in the golangci config only match
the exact directory names, so nested files under those directories are still
linted. Update the path regexes in the duplicated paths sections of the
configuration to match the directory as a path component, using the existing
exclusion entries for third_party, builtin, and examples as the anchors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 530f71e2-c681-4225-afed-72780bc8cc2f

📥 Commits

Reviewing files that changed from the base of the PR and between 31135a0 and 97bc271.

📒 Files selected for processing (1)
  • .golangci.yml

Comment thread .golangci.yml
@@ -1,65 +1,52 @@
# Originally copied from github.com/stackrox/stackrox, and regularly kept in-sync manually.

version: "2"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Config version:"
sed -n '1,6p' .golangci.yml

echo
echo "Pinned golangci-lint module(s):"
fd -a '^go\.mod$' tools 2>/dev/null | xargs -r rg -n 'github\.com/golangci/golangci-lint'

echo
echo "Makefile golangci-lint install/run entrypoints:"
rg -n -C2 'github\.com/golangci/golangci-lint(/v2)?/cmd/golangci-lint|\$\(GOLANGCILINT_BIN\) run' Makefile

Repository: stackrox/scanner

Length of output: 1251


🏁 Script executed:

# Example of incorrect vs correct behavior
# Incorrect: matches "third_party" but not "third_party/file.go"
# Correct: matches "third_party/" and "third_party/file.go"
third_party/

Repository: stackrox/scanner

Length of output: 201


Update exclusion path patterns and migrate to the v2 toolchain.

The configuration uses version: "2", but the Makefile installs golangci-lint from the v1 module path (github.com/golangci/golangci-lint at v1.64.8). While v1.64.8 detects v2 configs, consistency requires migrating the tool installation to github.com/golangci/golangci-lint/v2.

More critically, the exclusion patterns (e.g., third_party$) use a trailing $ anchor, which fails to exclude files inside those directories. In golangci-lint, the paths exclusion list treats trailing slashes as directory prefixes. Update the patterns (lines 114–116 and 127–129) to:

  • - third_party/
  • - builtin/
  • - examples/

Also update the v1 install command in the Makefile and tools/linters/go.mod to use the /v2 module path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.golangci.yml at line 3, The golangci-lint config and toolchain are
mismatched, and the exclusion patterns using trailing $ are not excluding
directory contents. Update the paths exclusions in the golangci-lint config to
use directory-prefix entries for third_party, builtin, and examples, and migrate
the lint tool installation to the /v2 module path in both the Makefile and
tools/linters/go.mod. Keep the version: "2" config aligned with the v2
golangci-lint module and verify the updated exclusions still apply through the
existing golangci-lint settings.

Comment thread .golangci.yml
Comment on lines +113 to +116
paths:
- third_party$
- builtin$
- examples$

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

python - <<'PY'
import re

current = [r"third_party$", r"builtin$", r"examples$"]
proposed = [r"(^|/)third_party(/|$)", r"(^|/)builtin(/|$)", r"(^|/)examples(/|$)"]
paths = [
    "third_party/foo.go",
    "pkg/third_party/foo.go",
    "builtin/foo.go",
    "examples/foo.go",
]

for path in paths:
    print(path)
    print("  current:", any(re.search(p, path) for p in current))
    print("  proposed:", any(re.search(p, path) for p in proposed))
PY

for d in third_party builtin examples; do
  echo
  echo "Sample files under $d, if present:"
  fd . "$d" -t f -d 2 2>/dev/null | head -5 || true
done

Repository: stackrox/scanner

Length of output: 491


Fix path exclusions to correctly exclude directory trees

The current regex patterns third_party$, builtin$, and examples$ in .golangci.yml are insufficient because they only match paths ending exactly at the directory name. Consequently, files inside these directories (e.g., third_party/foo.go) are not excluded and will still be processed by linters/formatters.

Update the patterns in both locations (lines 113–116 and 126–129) to match the directory as a path component.

Suggested update
     paths:
-    - third_party$
-    - builtin$
-    - examples$
+    - '(^|/)third_party(/|$)'
+    - '(^|/)builtin(/|$)'
+    - '(^|/)examples(/|$)'
@@
     paths:
-    - third_party$
-    - builtin$
-    - examples$
+    - '(^|/)third_party(/|$)'
+    - '(^|/)builtin(/|$)'
+    - '(^|/)examples(/|$)'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
paths:
- third_party$
- builtin$
- examples$
paths:
- '(^|/)third_party(/|$)'
- '(^|/)builtin(/|$)'
- '(^|/)examples(/|$)'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.golangci.yml around lines 113 - 116, The exclusion patterns in the golangci
config only match the exact directory names, so nested files under those
directories are still linted. Update the path regexes in the duplicated paths
sections of the configuration to match the directory as a path component, using
the existing exclusion entries for third_party, builtin, and examples as the
anchors.

@BradLugo BradLugo force-pushed the blugo/update-golangci-lint-config branch from 97bc271 to e3ee48e Compare June 26, 2026 08:35
@BradLugo BradLugo changed the base branch from master to blugo/remove-apollo-images June 26, 2026 08:35
Base automatically changed from blugo/remove-apollo-images to master June 26, 2026 18:53
@BradLugo BradLugo merged commit 1a300c5 into master Jun 26, 2026
35 of 36 checks passed
@BradLugo BradLugo deleted the blugo/update-golangci-lint-config branch June 26, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants