Skip to content

chore: upgrade golangci-lint to v2.12.2#55

Open
bramwelt wants to merge 2 commits into
mainfrom
chore/update-golangci-lint
Open

chore: upgrade golangci-lint to v2.12.2#55
bramwelt wants to merge 2 commits into
mainfrom
chore/update-golangci-lint

Conversation

@bramwelt

@bramwelt bramwelt commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Bump golangci-lint from v2.2.2 to v2.12.2 (built with go1.25.10) to resolve build failure against go 1.25.0. Fix four new lint issues surfaced by the upgrade.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 1, 2026 21:15
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR updates golangci-lint from v2.2.2 to v2.12.2, refactors interface compliance assertions in two test files to use direct nil-pointer type checks, and adjusts HTTP response cleanup to suppress close errors via an inline defer wrapper.

Changes

Tool Updates and Code Patterns

Layer / File(s) Summary
Golangci-lint version upgrade
Makefile
GOLANGCI_LINT_VERSION bumped to v2.12.2; lint target now installs github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) instead of the unversioned command at @latest.
Interface compliance assertion refactoring
cmd/service/service_test.go, internal/service/organization_search_test.go
TestQuerySvcsrvc_InterfaceCompliance and TestOrganizationSearchInterface updated to use direct (*ConcreteType)(nil) type assertions instead of interface-typed variables, tightening compile-time interface compliance checks.
HTTP response cleanup error suppression
pkg/httpclient/client.go
doRequest changes response body closure from bare defer resp.Body.Close() to defer func() { _ = resp.Body.Close() }() to explicitly suppress close errors.

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the main change: upgrading golangci-lint from v2.2.2 to v2.12.2, which is the primary objective of this PR.
Description check ✅ Passed The description relates to the changeset by explaining the upgrade reason and mentioning that lint issues were fixed, though it lacks detail on the specific code changes made.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/update-golangci-lint

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

Copilot AI 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.

Pull request overview

Updates the repository’s Go lint tooling to a newer golangci-lint release to restore compatibility with newer Go toolchains, and adjusts a few code/test patterns to satisfy newly-enabled lint checks.

Changes:

  • Bump golangci-lint version in the Makefile to v2.12.2.
  • Address new lint findings by explicitly ignoring Close() errors on HTTP response bodies.
  • Update interface compliance tests to use compile-time assertions against concrete types and suppress a new staticcheck finding.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pkg/httpclient/client.go Adjusts response body close handling to satisfy errcheck-style linting.
Makefile Pins golangci-lint version to v2.12.2 (but the lint target install command still appears inconsistent with v2).
internal/service/organization_search_test.go Updates interface compliance assertions and adds a //nolint:staticcheck suppression (which appears avoidable).
cmd/service/service_test.go Updates interface compliance assertion to a compile-time check against the concrete service type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/service/organization_search_test.go Outdated
Comment thread Makefile
Bump golangci-lint from v2.2.2 to v2.12.2 (built with
go1.25.10) to resolve build failure against go 1.25.0.
Fix four new lint issues surfaced by the upgrade.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
@bramwelt bramwelt force-pushed the chore/update-golangci-lint branch from 2da0b81 to 250cdae Compare June 1, 2026 23:04
@bramwelt

bramwelt commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Review Feedback Addressed

Commit: 250cdae

Changes Made

  • Makefile:57: Updated lint target fallback install from v1 module path to github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) (per copilot-pull-request-reviewer[bot])
  • internal/service/organization_search_test.go:769: Removed explicit OrganizationSearcher type annotation and //nolint:staticcheck; changed to short declaration (per copilot-pull-request-reviewer[bot])

Threads Resolved

2 of 2 unresolved threads addressed.

@bramwelt bramwelt marked this pull request as ready for review June 1, 2026 23:06
Copilot AI review requested due to automatic review settings June 1, 2026 23:06
@bramwelt bramwelt requested a review from a team as a code owner June 1, 2026 23:06

Copilot AI 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread Makefile
Comment on lines 55 to 58
lint: ## Run golangci-lint (local Go linting)
@echo "Running golangci-lint..."
@which golangci-lint >/dev/null 2>&1 || (echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
@which golangci-lint >/dev/null 2>&1 || (echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))
@golangci-lint run ./... && echo "==> Lint OK"

@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.

🧹 Nitpick comments (1)
cmd/service/service_test.go (1)

590-599: 💤 Low value

Consider simplifying the test now that compile-time check uses nil pointer.

The test instantiates service with mocks (lines 592-595) but only uses it for a NotNil assertion (line 598). Since the interface compliance check now uses the nil pointer pattern (*querySvcsrvc)(nil), you could either:

  1. Remove the service instantiation and NotNil check entirely (the compile-time check is sufficient for interface compliance)
  2. Move the construction and NotNil check to a separate test if you want to verify the constructor behavior

The current code works fine, but streamlining would make the test's intent clearer.

♻️ Optional streamlined version
 func TestQuerySvcsrvc_InterfaceCompliance(t *testing.T) {
-	// Verify that querySvcsrvc implements the querysvc.Service interface
-	mockResourceSearcher := mock.NewMockResourceSearcher()
-	mockAccessChecker := mock.NewMockAccessControlChecker()
-	mockOrgSearcher := mock.NewMockOrganizationSearcher()
-	service := NewQuerySvc(mockResourceSearcher, mockAccessChecker, mock.NewMockResourceFilter(), mockOrgSearcher, mock.NewMockAuthService())
-
+	// Compile-time check that querySvcsrvc implements querysvc.Service
 	var _ querysvc.Service = (*querySvcsrvc)(nil)
-	assert.NotNil(t, service)
 }
🤖 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 `@cmd/service/service_test.go` around lines 590 - 599, The test
TestQuerySvcsrvc_InterfaceCompliance should only perform the compile-time
interface check using (*querySvcsrvc)(nil); remove the unnecessary runtime
instantiation and assert by deleting the mock setup
(mock.NewMockResourceSearcher, mock.NewMockAccessControlChecker,
mock.NewMockOrganizationSearcher, mock.NewMockResourceFilter,
mock.NewMockAuthService) and the assert.NotNil(t, service) lines, or if you want
to keep constructor verification, move that instantiation and the NotNil
assertion into a separate test (e.g., TestNewQuerySvc_ReturnsNonNil) that calls
NewQuerySvc and asserts non-nil.
🤖 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.

Nitpick comments:
In `@cmd/service/service_test.go`:
- Around line 590-599: The test TestQuerySvcsrvc_InterfaceCompliance should only
perform the compile-time interface check using (*querySvcsrvc)(nil); remove the
unnecessary runtime instantiation and assert by deleting the mock setup
(mock.NewMockResourceSearcher, mock.NewMockAccessControlChecker,
mock.NewMockOrganizationSearcher, mock.NewMockResourceFilter,
mock.NewMockAuthService) and the assert.NotNil(t, service) lines, or if you want
to keep constructor verification, move that instantiation and the NotNil
assertion into a separate test (e.g., TestNewQuerySvc_ReturnsNonNil) that calls
NewQuerySvc and asserts non-nil.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cbfceb9a-a281-4f41-b682-0739f2af559d

📥 Commits

Reviewing files that changed from the base of the PR and between d8dc629 and 8822410.

📒 Files selected for processing (4)
  • Makefile
  • cmd/service/service_test.go
  • internal/service/organization_search_test.go
  • pkg/httpclient/client.go

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