Skip to content

Use golangci-lint#902

Merged
yamatcha merged 12 commits intomainfrom
golangci-lint
Mar 27, 2026
Merged

Use golangci-lint#902
yamatcha merged 12 commits intomainfrom
golangci-lint

Conversation

@yamatcha
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread controllers/mysqlcluster_controller.go Outdated
Comment thread controllers/mysqlcluster_controller.go Outdated
Comment thread api/v1beta2/backuppolicy_types.go
Comment thread .golangci.yml
Comment thread backup/backup.go Outdated
Comment thread backup/backup.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces golangci-lint as the unified Go linting tool (installed via Aqua and run in CI) and applies repo-wide code updates to satisfy the newly enabled linters.

Changes:

  • Add golangci-lint (Aqua + config) and wire it into CI via make lint.
  • Refactor codebase to address lints/modernization (e.g., any, range over ints, *Seq string helpers, explicit error discards, reduced cyclomatic warnings).
  • Simplify some controller helper signatures and remove now-unnecessary request plumbing.

Reviewed changes

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

Show a summary per file
File Description
pkg/event/event.go Modernize variadic type from interface{} to any.
pkg/dbop/test_util.go Use strings.FieldsSeq iteration for cleanup loop.
pkg/dbop/replication.go Switch-based version selection for replication command.
pkg/dbop/operator.go Add //nolint:nilerr for intentional nil-error return.
pkg/dbop/gtid.go Modernize slice loop using range.
pkg/dbop/driver.go Modernize logger signature; explicitly ignore SetLogger return.
pkg/bucket/s3_test.go Modernize integer loop using range over int.
pkg/bucket/gcs_test.go Modernize integer loop using range over int.
pkg/bucket/azure_test.go Modernize integer loop using range over int.
pkg/bkop/status.go Switch-based version handling for status query differences.
pkg/bkop/restore.go Make ignored Close calls explicit for errcheck.
pkg/bkop/operator.go Explicitly ignore DB close error.
e2e/run_test.go Use promoted pvc.Labels field.
e2e/prevent_delete_test.go Modernize integer loops using range over int.
e2e/failure_test.go Use WaitGroup.Go pattern to reduce goroutine boilerplate.
controllers/suite_test.go Modernize channel element type to any.
controllers/pvc_test.go Update tests for new reconcilePVC/needResizePVC signatures.
controllers/pvc.go Simplify reconcilePVC API; embed-client calls; remove unused error path.
controllers/partition_controller.go Use embedded client methods (List, Patch).
controllers/mysqlcluster_controller.go Use maps.Copy; simplify reconcile helpers’ signatures; add nolint:gocyclo; minor time comparison update.
controllers/mysql_container.go Use max for probe threshold; remove now-unneeded loopvar copies.
controllers/certificate.go Simplify helpers’ signatures; use embedded client methods (Get, Create).
cmd/moco-backup/cmd/root.go Return os.Setenv error instead of ignoring.
cmd/moco-backup/cmd/restore.go Modernize retry loop using range over int.
cmd/kubectl-moco/cmd/mysql.go Drop unused context parameter in getPodName call.
cmd/kubectl-moco/cmd/common.go Simplify getPodName signature (remove unused ctx).
clustering/status_test.go Remove loopvar copy now unnecessary with modern Go.
clustering/status.go Ignore close errors; add nolint:gocyclo; use strings.SplitSeq.
clustering/operations.go Explicitly ignore close errors; modernize loops; make named returns explicit.
clustering/mock_test.go Use strings.SplitSeq in GTID parsing helpers.
clustering/metrics_test.go Modernize matcher method signatures to any.
clustering/manager_test.go Modernize integer loops; update Eventually return types to any.
clustering/manager.go Use WaitGroup.Go pattern for process goroutine.
backup/restore.go Modernize loops; explicitly ignore cleanup/close errors.
backup/integration_test.go Modernize integer loop using range over int.
backup/bytecounter_test.go Remove redundant cast in byte-count assertion.
backup/backup.go Explicitly ignore cleanup/close errors; minor type simplification.
aqua.yaml Add golangci/golangci-lint to Aqua-managed tools.
aqua-checksums.json Add checksums for golangci-lint artifacts.
api/v1beta2/statefulset_webhhok.go Use promoted APIVersion field.
api/v1beta2/mysqlcluster_types.go Add nolint annotations; fix spelling; modernize switch style.
api/v1beta2/backuppolicy_types.go Add nolint:unparam for validation helper.
Makefile Add lint target; remove direct staticcheck/nilerr tool install; adjust test target.
.golangci.yml New golangci-lint v2 config enabling selected linters/formatters.
.github/workflows/ci.yaml Run make lint in CI before make test.

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

Comment thread controllers/pvc_test.go
Comment on lines 331 to 335
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
r := &MySQLClusterReconciler{}
resizeTarget, resize, err := r.needResizePVC(tt.cluster, tt.sts)
if tt.wantError != nil {
if !errors.Is(err, tt.wantError) {
t.Fatalf("want error %v, got %v", tt.wantError, err)
}
}

resizeTarget, resize := r.needResizePVC(tt.cluster, tt.sts)
if tt.wantResize != resize {
Comment thread clustering/operations.go
}
}
return
return redo, e
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.

戻り値が (redo bool, e error) になっているものの、実際には e に何か値を設定している箇所は無いようです。 return redo, ereturn redo, nil に置き換えられそうです。

yamatcha added 12 commits March 26, 2026 04:24
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
Signed-off-by: yamatcha <soju-yamashita@cybozu.co.jp>
@yamatcha yamatcha merged commit 722559b into main Mar 27, 2026
22 checks passed
@yamatcha yamatcha deleted the golangci-lint branch March 27, 2026 05:04
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.

4 participants