-
Notifications
You must be signed in to change notification settings - Fork 150
Description
✅ Current Behavior
Running make check
on the meshkit
project produces a large number of warnings and suggestions from golangci-lint
, including:
-
30 unchecked error return values (e.g.,
defer file.Close()
,os.RemoveAll()
) -
Use of deprecated packages or APIs, such as:
nats.EncodedConn
(no longer supported)opa/rego
,opa/storage/inmem
(deprecated since OPA v1.x)
-
Improper formatting in error messages, such as:
- Capitalized error strings (
ST1005
) - Errors ending with punctuation
- Capitalized error strings (
-
Ineffectual assignments (e.g., assigned value to
err
never used) -
Incorrect
Printf
-style formatting withlogrus.Info
-
Multiple redundant or outdated imports (e.g., importing
"k8s.io/api/core/v1"
twice) -
Staticcheck issues, including:
- Use of deprecated constants (
oras.PackManifestVersion1_1_RC4
) - Suggestions to use
strings.ReplaceAll
instead ofstrings.Replace
- Opportunities to simplify code using tagged switches or merged assignments
- Use of deprecated constants (
These warnings are spread across a wide number of files including:
files/
,models/
,utils/
,generator/
,broker/
, andcmd/
Execution took 9+ minutes, showing long analysis time due to complexity and volume.
✅ Expected Behavior
-
make check
should complete without producing lint warnings or errors. -
All error return values should be properly handled.
-
No deprecated APIs or packages should be used.
-
Error strings should follow Go formatting guidelines:
- Begin with lowercase
- Do not end in punctuation or newlines
-
Code should follow best practices suggested by
staticcheck
,govet
,ineffassign
, anderrcheck
. -
The codebase should be fully compliant with the configured
.golangci.yml
rules.
Screenshots/Logs
PS D:\Programs\meshkit\meshkit> make check GOLANGCI_LINT_EXTRA_ARGS="--timeout 30m"
golangci-lint run -c .golangci.yml -v --timeout 30m ./...
level=info msg="golangci-lint has version 2.2.0 built with go1.24.4 from 1e7781b6 on 2025-06-28T20:40:39Z"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[config_reader] Module name \"github.com/meshery/meshkit\""
level=info msg="maxprocs: Leaving GOMAXPROCS=4: CPU quota undefined"
level=info msg="[goenv] Read go env for 190.5329ms: map[string]string{\"GOCACHE\":\"C:\\\\Users\\\\user\\\\AppData\\\\Local\\\\go-build\", \"GOROOT\":\"C:\\\\Program Files\\\\Go\"}"
level=info msg="[lintersdb] Active 5 linters: [errcheck govet ineffassign staticcheck unused]"
level=info msg="[loader] Go packages loading at mode 8767 (imports|name|deps|files|types_sizes|compiled_files|exports_file) took 5m44.2263696s"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 89.8965ms"
level=info msg="[linters_context/goanalysis] analyzers took 14m15.5148314s with top 10 stages: buildir: 6m39.3227668s, nilness: 1m9.7619426s, fact_purity: 1m1.7734597s, typedness: 1m1.35414s, SA5012: 56.4320969s, ctrlflow: 54.5981621s, printf: 54.2307067s, fact_deprecated: 53.1918186s, inspect: 10.6342958s, tokenfileanalyzer: 4.6703691s"
level=info msg="[runner/max_same_issues] 24/27 issues with text \"ST1005: error strings should not be capitalized\" were hidden, use --max-same-issues"
level=info msg="[runner/max_same_issues] 4/7 issues with text \"QF1001: could apply De Morgan's law\" were hidden, use --max-same-issues"
level=info msg="[runner/max_same_issues] 3/6 issues with text \"Error return value of `os.RemoveAll` is not checked\" were hidden, use --max-same-issues"
level=info msg="[runner/max_same_issues] 2/5 issues with text \"Error return value of `file.Close` is not checked\" were hidden, use --max-same-issues"
level=info msg="[runner/max_same_issues] 1/4 issues with text \"Error return value of `resp.Body.Close` is not checked\" were hidden, use --max-same-issues"
level=info msg="[runner/max_same_issues] 1/4 issues with text \"QF1004: could use strings.ReplaceAll instead\" were hidden, use --max-same-issues"
level=info msg="[runner] Issues before processing: 126, after processing: 80"
level=info msg="[runner] Processors filtering stat (in/out): path_absoluter: 126/126, cgo: 126/126, filename_unadjuster: 126/126, path_relativity: 126/126, exclusion_rules: 126/126, max_per_file_from_linter: 115/115, source_code: 80/80, path_shortener: 80/80, generated_file_filter: 126/126, fixer: 121/121, max_from_linter: 80/80, severity-rules: 80/80, invalid_issue: 126/126, exclusion_paths: 126/126, diff: 121/121, uniq_by_line: 121/115, path_prettifier: 80/80, nolint_filter: 126/121, max_same_issues: 115/80, sort_results: 80/80"
level=info msg="[runner] processing took 84.3021ms with stages: nolint_filter: 52.5468ms, generated_file_filter: 14.4235ms, source_code: 10.7618ms, max_same_issues: 4.001ms, invalid_issue: 1.2575ms, cgo: 797.5µs, path_relativity: 514µs, path_shortener: 0s, max_per_file_from_linter: 0s, sort_results: 0s, filename_unadjuster: 0s, path_absoluter: 0s, fixer: 0s, uniq_by_line: 0s, exclusion_rules: 0s, exclusion_paths: 0s, diff: 0s, max_from_linter: 0s, severity-rules: 0s, path_prettifier: 0s"
level=info msg="[runner] linters took 3m22.9382754s with stages: goanalysis_metalinter: 3m22.8473147s"
converter\tests\helm_test.go:130:16: Error return value of `gr.Close` is not checked (errcheck)
defer gr.Close()
^
converter\tests\helm_test.go:142:11: Error return value of `io.Copy` is not checked (errcheck)
io.Copy(buf, tr)
^
files\identification.go:112:20: Error return value of `os.RemoveAll` is not checked (errcheck)
defer os.RemoveAll(tmpDir)
^
files\identification.go:119:18: Error return value of `file.Close` is not checked (errcheck)
defer file.Close()
^
files\sanitization.go:95:25: Error return value of `gzipReader.Close` is not checked (errcheck)
defer gzipReader.Close()
^
files\sanitization.go:135:19: Error return value of `file.Close` is not checked (errcheck)
defer file.Close()
^
files\sanitization.go:181:22: Error return value of `zipFile.Close` is not checked (errcheck)
defer zipFile.Close()
^
files\sanitization.go:188:22: Error return value of `outFile.Close` is not checked (errcheck)
defer outFile.Close()
^
generators\artifacthub\package.go:143:23: Error return value of `resp.Body.Close` is not checked (errcheck)
defer resp.Body.Close()
^
generators\artifacthub\package.go:163:24: Error return value of `resp.Body.Close` is not checked (errcheck)
defer resp.Body.Close()
^
generators\github\git_repo.go:50:11: Error return value of `br.Flush` is not checked (errcheck)
br.Flush()
^
generators\github\git_repo.go:51:11: Error return value of `fd.Close` is not checked (errcheck)
fd.Close()
^
models\oci\oci.go:97:21: Error return value of `os.RemoveAll` is not checked (errcheck)
defer os.RemoveAll(tmpDir)
^
models\oci\oci.go:201:16: Error return value of `fs.Close` is not checked (errcheck)
defer fs.Close()
^
models\oci\utils.go:89:18: Error return value of `gzr.Close` is not checked (errcheck)
defer gzr.Close()
^
models\oci\utils.go:121:18: Error return value of `gzr.Close` is not checked (errcheck)
defer gzr.Close()
^
utils\kubernetes\apply-helm-chart.go:412:11: Error return value of `os.Setenv` is not checked (errcheck)
os.Setenv("HELM_DRIVER_SQL_CONNECTION_STRING", cfg.SQLConnectionString)
^
utils\kubernetes\kompose\convert.go:50:12: Error return value of `os.Remove` is not checked (errcheck)
os.Remove(tempFilePath)
^
utils\kubernetes\kompose\convert.go:51:12: Error return value of `os.Remove` is not checked (errcheck)
os.Remove(resultFilePath)
^
utils\unarchive.go:161:17: Error return value of `outFile.Close` is not checked (errcheck)
outFile.Close()
^
utils\utils.go:115:23: Error return value of `resp.Body.Close` is not checked (errcheck)
defer resp.Body.Close()
^
utils\utils.go:126:17: Error return value of `out.Close` is not checked (errcheck)
defer out.Close()
^
utils\utils.go:149:11: Error return value of `fd.Close` is not checked (errcheck)
fd.Close()
^
utils\utils.go:187:27: Error return value of `response.Body.Close` is not checked (errcheck)
defer response.Body.Close()
^
utils\utils.go:374:18: Error return value of `file.Close` is not checked (errcheck)
defer file.Close()
^
utils\utils.go:379:21: Error return value of `encoder.Close` is not checked (errcheck)
defer encoder.Close()
^
utils\utils.go:564:16: Error return value of `zr.Close` is not checked (errcheck)
defer zr.Close()
^
utils\utils.go:566:16: Error return value of `tw.Close` is not checked (errcheck)
defer tw.Close()
^
utils\utils.go:593:20: Error return value of `data.Close` is not checked (errcheck)
defer data.Close()
^
utils\walker\git.go:147:15: Error return value of `os.RemoveAll` is not checked (errcheck)
os.RemoveAll(path)
^
utils\component\generator.go:75:3: printf: github.com/sirupsen/logrus.Info call has possible Printf formatting directive %v (govet)
logrus.Info("Failed to extract group from crd %v", err)
^
generators\github\url.go:57:9: ineffectual assignment to err (ineffassign)
data, err := os.ReadFile(downloadfilePath)
^
broker\nats\nats.go:28:6: SA1019: nats.EncodedConn is deprecated: Encoded connections are no longer supported. (staticcheck)
ec *nats.EncodedConn
^
broker\nats\nats.go:60:13: SA1019: nats.NewEncodedConn is deprecated: Encoded connections are no longer supported. (staticcheck)
ec, err := nats.NewEncodedConn(nc, nats.JSON_ENCODER)
^
broker\nats\nats.go:82:2: SA1019: n.ec.Close is deprecated: Encoded connections are no longer supported. (staticcheck)
n.ec.Close()
^
broker\nats\nats.go:87:9: SA1019: n.ec.Publish is deprecated: Encoded connections are no longer supported. (staticcheck)
err := n.ec.Publish(subject, message)
^
broker\nats\nats.go:96:9: SA1019: n.ec.BindSendChan is deprecated: Encoded connections are no longer supported. (staticcheck)
err := n.ec.BindSendChan(subject, msgch)
^
broker\nats\nats.go:108:12: SA1019: n.ec.QueueSubscribe is deprecated: Encoded connections are no longer supported. (staticcheck)
_, err := n.ec.QueueSubscribe(subject, queue, func(msg *nats.Msg) {
^
broker\nats\nats.go:122:12: SA1019: n.ec.BindRecvQueueChan is deprecated: Encoded connections are no longer supported. (staticcheck)
_, err := n.ec.BindRecvQueueChan(subject, queue, msgch)
^
cmd\errorutil\internal\coder\errorsnew_test.go:67:6: QF1001: could apply De Morgan's law (staticcheck)
if !(e.Name == "ErrTestNewCode1" || e.Name == "ErrTestNewCode2" || e.Name == "ErrTestNewCode3") {
^
cmd\errorutil\internal\coder\errorsnew_test.go:71:7: QF1001: could apply De Morgan's law (staticcheck)
if !(e.Severity == "Fatal" &&
^
cmd\errorutil\internal\coder\errorsnew_test.go:80:7: QF1001: could apply De Morgan's law (staticcheck)
if !(e.Severity == "None" &&
^
encoding\convert.go:21:15: ST1005: error strings should not end with punctuation or newlines (staticcheck)
return nil, fmt.Errorf("No content found in the yaml file.")
^
files\conversion.go:14:14: ST1005: error strings should not be capitalized (staticcheck)
return "", fmt.Errorf("Failed to get *chart.Chart from identified file")
^
files\conversion.go:27:14: ST1005: error strings should not be capitalized (staticcheck)
return "", fmt.Errorf("Failed to get *chart.Chart from identified file")
^
files\conversion.go:37:14: ST1005: error strings should not be capitalized (staticcheck)
return "", fmt.Errorf("Failed to get *resmap.ResMap from identified file")
^
models\controllers\meshery_operator.go:80:30: ST1005: error strings should not end with punctuation or newlines (staticcheck)
return ErrDeployController(fmt.Errorf("Already a Meshery Operator is being deployed."))
^
models\meshmodel\core\policies\rego_policy_relationship.go:13:2: SA1019: "github.com/open-policy-agent/opa/rego" is deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. For newer features and behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in the [github.com/open-policy-agent/opa/v1] package instead. See https://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information. (staticcheck)
"github.com/open-policy-agent/opa/rego"
^
models\meshmodel\core\policies\rego_policy_relationship.go:14:2: SA1019: "github.com/open-policy-agent/opa/storage" is deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. For newer features and
behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in the [github.com/open-policy-agent/opa/v1] package instead. See https://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information. (staticcheck)
"github.com/open-policy-agent/opa/storage"
^
models\meshmodel\core\policies\rego_policy_relationship.go:15:2: SA1019: "github.com/open-policy-agent/opa/storage/inmem" is deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. For newer features and behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in the [github.com/open-policy-agent/opa/v1] package instead. See https://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information. (staticcheck)
"github.com/open-policy-agent/opa/storage/inmem"
^
models\meshmodel\core\policies\rego_policy_relationship.go:16:2: SA1019: "github.com/open-policy-agent/opa/topdown/print" is deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. For newer features and behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in the [github.com/open-policy-agent/opa/v1] package instead. See https://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information. (staticcheck)
"github.com/open-policy-agent/opa/topdown/print"
^
models\meshmodel\registry\v1beta1\component_filter.go:104:2: QF1003: could use tagged switch on componentFilter.Annotations (staticcheck)
if componentFilter.Annotations == "true" {
^
models\meshmodel\registry\v1beta1\model_filter.go:125:2: QF1003: could use tagged switch on mf.Annotations (staticcheck)
if mf.Annotations == "true" {
^
models\meshmodel\registry\v1beta1\model_filter.go:139:2: QF1003: could use tagged switch on mf.Annotations (staticcheck)
if mf.Annotations == "true" {
^
models\oci\oci.go:150:63: SA1019: oras.PackManifestVersion1_1_RC4 is deprecated: This constant is deprecated and not recommended for future use. Use [PackManifestVersion1_1] instead. (staticcheck)
manifestDescriptor, packageErr := oras.PackManifest(ctx, fs, oras.PackManifestVersion1_1_RC4, artifactType, opts)
^
registry\component.go:138:3: QF1003: could use tagged switch on key (staticcheck)
if key == "genealogy" {
^
registry\model.go:129:4: QF1003: could use tagged switch on key (staticcheck)
if key == "svgColor" {
^
registry\model.go:139:5: QF1003: could use tagged switch on key (staticcheck)
if key == "svgColor" {
^
registry\model.go:320:15: ST1023: should omit type string from declaration; it will be inferred from the right-hand side (staticcheck)
var template string = `---
^
registry\model.go:419:2: QF1003: could use tagged switch on outputFor (staticcheck)
if outputFor == "mesherydocs" {
^
utils\component\generator.go:118:2: QF1003: could use tagged switch on scope (staticcheck)
if scope == "Cluster" {
^
utils\component\openapi_generator.go:111:5: QF1003: could use tagged switch on scope (staticcheck)
if scope == "Namespaced" {
^
utils\kubernetes\expose\expose.go:10:2: ST1019: package "k8s.io/api/core/v1" is being imported more than once (staticcheck)
corev1 "k8s.io/api/core/v1"
^
utils\kubernetes\expose\expose.go:11:2: ST1019(related information): other import of "k8s.io/api/core/v1" (staticcheck)
v1 "k8s.io/api/core/v1"
^
utils\kubernetes\get-manifests.go:17:16: ST1023: should omit type string from declaration; it will be inferred from the right-hand side (staticcheck)
var manifests string = ""
^
utils\kubernetes\kubernetes.go:24:16: QF1008: could remove embedded field "TLSClientConfig" from selector (staticcheck)
if restConfig.TLSClientConfig.Insecure {
^
utils\kubernetes\kubernetes.go:25:14: QF1008: could remove embedded field "TLSClientConfig" from selector (staticcheck)
restConfig.TLSClientConfig.Insecure = true
^
utils\kubernetes\service.go:58:3: QF1003: could use tagged switch on obj.Status.LoadBalancer.Ingress[0].IP (staticcheck)
if obj.Status.LoadBalancer.Ingress[0].IP == "" {
^
utils\kubernetes\service_test.go:9:2: ST1019: package "k8s.io/api/core/v1" is being imported more than once (staticcheck)
corev1 "k8s.io/api/core/v1"
^
utils\kubernetes\service_test.go:10:2: ST1019(related information): other import of "k8s.io/api/core/v1" (staticcheck)
v1 "k8s.io/api/core/v1"
^
utils\manifests\utils.go:43:6: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
def.ObjectMeta.Name = resourceId
^
utils\manifests\utils.go:61:8: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
def.ObjectMeta.Name += "." + cfg.Type
^
utils\manifests\utils.go:72:7: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
def.ObjectMeta.Name += ".K8s"
^
utils\sortversions.go:56:6: QF1004: could use strings.ReplaceAll instead (staticcheck)
s = strings.Replace(s, "alpha", ".0", -1)
^
utils\sortversions.go:57:6: QF1004: could use strings.ReplaceAll instead (staticcheck)
s = strings.Replace(s, "beta", ".1", -1)
^
utils\sortversions.go:58:6: QF1004: could use strings.ReplaceAll instead (staticcheck)
s = strings.Replace(s, "rc", ".2", -1)
^
utils\svg_utils.go:46:6: QF1003: could use tagged switch on a.Name.Local (staticcheck)
if a.Name.Local == "width" {
^
utils\utils.go:218:10: ST1023: should omit type string from declaration; it will be inferred from the right-hand side (staticcheck)
var url string = "https://github.com/" + org + "/" + repo + "/releases"
^
utils\utils.go:892:10: ST1005: error strings should not end with punctuation or newlines (staticcheck)
return fmt.Errorf("%s...", strings.Join(words, " "))
^
utils\walker\github.go:133:2: QF1007: could merge conditional assignment into variable declaration (staticcheck)
isFile := true
^
80 issues:
* errcheck: 30
* govet: 1
* ineffassign: 1
* staticcheck: 48
level=info msg="File cache stats: 34 entries of total size 241.4KiB"
level=info msg="Memory: 4998 samples, avg is 377.8MB, max is 2266.2MB"
level=info msg="Execution took 9m7.6942676s"
make: *** [Makefile:6: check] Error 1
PS D:\Programs\meshkit\meshkit>
Environment
-
Host OS: Windows 10
-
Platform: Native (not using Docker or Kubernetes for this lint check)
-
Meshkit Version: Latest
main
branch (as of July 2025) -
Golang Version:
go1.24.4
-
golangci-lint Version:
2.2.0
(built on 2025-06-28) -
Command Used:
make check GOLANGCI_LINT_EXTRA_ARGS="--timeout 30m"
Contributor Guides and Handbook
- 🛠 Meshery Build & Release Strategy
- 📚 Instructions for contributing to documentation
- 🎨 Wireframes and designs for Meshery UI in Figma (open invite)
- 🙋🏾🙋🏼 Questions: Discussion Forum and Community Slack