diff --git a/.github/workflows/project-check.yml b/.github/workflows/project-check.yml index b7f31ec76c3..5e9cfc0dc19 100644 --- a/.github/workflows/project-check.yml +++ b/.github/workflows/project-check.yml @@ -47,7 +47,7 @@ jobs: path: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid - name: Lint golang code - uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2 + uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1 with: version: latest args: --timeout 10m --verbose diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000000..8123c03a82d --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,22 @@ +version: "2" + +linters: + settings: + staticcheck: + checks: + - all + # Disable quickfix suggestions (refactoring hints, not bugs) + - "-QF1001" # could apply De Morgan's law + - "-QF1004" # could use strings.ReplaceAll instead + - "-QF1007" # could merge conditional assignment into variable declaration + - "-QF1008" # could remove embedded field from selector + - "-QF1011" # could omit type from declaration + # Disable style checks that are auto-fixable but noisy + - "-ST1023" # should omit type from declaration; it will be inferred from the right-hand side + +issues: + exclude-rules: + # Ignore unchecked errors in test files (common Go test pattern for setup/cleanup) + - path: "_test\\.go" + linters: + - errcheck diff --git a/pkg/ddc/juicefs/transform.go b/pkg/ddc/juicefs/transform.go index 0c08a13425e..eba30405263 100644 --- a/pkg/ddc/juicefs/transform.go +++ b/pkg/ddc/juicefs/transform.go @@ -160,7 +160,7 @@ func (j *JuiceFSEngine) transformWorkers(runtime *datav1alpha1.JuiceFSRuntime, d // send an event in runtime msg := "cache-size & cache-dir in worker.options will be deprecated in the future, please use tieredStore.levels instead" j.Log.Info(msg) - j.Recorder.Eventf(runtime, corev1.EventTypeWarning, common.RuntimeDeprecated, msg) + j.Recorder.Eventf(runtime, corev1.EventTypeWarning, common.RuntimeDeprecated, "%s", msg) } // transform mount cmd & stat cmd diff --git a/pkg/utils/metadata.go b/pkg/utils/metadata.go index 846106c1ece..651ae67e22d 100644 --- a/pkg/utils/metadata.go +++ b/pkg/utils/metadata.go @@ -59,7 +59,7 @@ func LoadCurrentFuseGenerationFromMeta(namespace, name, runtimeType string) (str if err != nil { return "", errors.Wrapf(err, "failed to open metadata file %s", filePath) } - defer file.Close() + defer func() { _ = file.Close() }() scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text()