lint/strict/go
golangci-lint enables the baseline linters
Implements lint/strict for go.
| Severity | warning |
| Tiers | 1, 2 |
| Stacks | go |
| Scope | each |
| Kind | expr |
| Source | library v0.8.0 |
| Selected by | fleetlint-recommended@v0.8.0 |
Requirement
The golangci-lint v2 configuration enables every linter in params.required (errcheck, govet, staticcheck, errorlint, gosec, gocognit, funlen), through enable, default: all or the standard set, and does not list it under disable.
Why
Swallowed errors, unsafe calls and oversized functions are exactly what these linters catch.
Applies when
[["", "../", "../../", "../../../"].map(d, [".golangci.yml", ".golangci.yaml", ".golangci.toml", ".golangci.json"].map(n, d + n))
.flatten().filter(f, file(f))]
.exists(l, l.size() > 0 && [l[0].endsWith(".toml") ? toml(l[0]) : (l[0].endsWith(".json") ? json(l[0]) : yaml(l[0]))]
.exists(c, c != null && has(c.version) && string(c.version) == "2"))Check
For each item in:
params.required[["", "../", "../../", "../../../"].map(d, [".golangci.yml", ".golangci.yaml", ".golangci.toml", ".golangci.json"].map(n, d + n))
.flatten().filter(f, file(f))]
.exists(l, [l[0].endsWith(".toml") ? toml(l[0]) : (l[0].endsWith(".json") ? json(l[0]) : yaml(l[0]))]
.exists(c, (!has(c.linters) || c.linters == null)
? item in ["errcheck", "govet", "ineffassign", "staticcheck", "unused"]
: !(has(c.linters.disable) && item in c.linters.disable)
&& ((has(c.linters.enable) && item in c.linters.enable)
|| (has(c.linters.default) && c.linters.default == "all")
|| ((!has(c.linters.default) || c.linters.default == "standard")
&& item in ["errcheck", "govet", "ineffassign", "staticcheck", "unused"]))))Parameters
required:[errcheck govet staticcheck errorlint gosec gocognit funlen]
Fix
Add the missing linters to linters.enable in .golangci.yml and remove them from linters.disable.
Agent instruction: Add each reported linter to the linters.enable list in .golangci.yml (and drop it from linters.disable); keep the rest of the file unchanged.
Sources
- https://fleetlint.org/baseline/#static-analysis (convention)
- https://golangci-lint.run/docs/linters/ (spec)
- https://pkg.go.dev/cmd/vet (spec)
- https://staticcheck.dev/docs/checks/ (check)
- https://golangci-lint.run/docs/linters/configuration/ (check, errorlint)
- https://github.com/securego/gosec (check)
- https://fleetlint.org/stacks/#go
Generated by fleetlint docs from catalog v0.8.0.