fleetlint Policy for a fleet of repositories
v0.4
Getting started

lint/strict/go

golangci-lint enables the baseline linters

Implements lint/strict for go.

Severitywarning
Tiers1, 2
Stacksgo
Scopeeach
Kindexpr
Sourcelibrary v0.1.0
Selected byfleetlint-recommended@v0.1.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.

See: https://fleetlint.org/baseline/#static-analysis, https://fleetlint.org/stacks/#go


Generated by fleetlint docs from catalog v0.1.0.