diff --git a/Makefile b/Makefile index d6fd25517..581c469f5 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,8 @@ fmt: # Run all the linters lint: - golangci-lint run --tests=false --enable-all ./... + # TODO: fix tests and lll issues + ./bin/golangci-lint run --tests=false --enable-all --disable=lll ./... find . -name '*.md' -not -wholename './vendor/*' | xargs prettier -l .PHONY: lint diff --git a/internal/builders/golang/build.go b/internal/builders/golang/build.go index 13b5311f3..2237fadac 100644 --- a/internal/builders/golang/build.go +++ b/internal/builders/golang/build.go @@ -55,7 +55,7 @@ func (*Builder) WithDefaults(build config.Build) config.Build { // Build builds a golang build func (*Builder) Build(ctx *context.Context, build config.Build, options api.Options) error { - if err := checkMain(ctx, build); err != nil { + if err := checkMain(build); err != nil { return err } cmd := []string{"go", "build"} @@ -187,7 +187,7 @@ func (b buildTarget) Env() []string { } } -func checkMain(ctx *context.Context, build config.Build) error { +func checkMain(build config.Build) error { var main = build.Main if main == "" { main = "." diff --git a/internal/builders/golang/targets.go b/internal/builders/golang/targets.go index 068e19707..856ab399a 100644 --- a/internal/builders/golang/targets.go +++ b/internal/builders/golang/targets.go @@ -19,6 +19,7 @@ func (t target) String() string { } func matrix(build config.Build) (result []string) { + // nolint:prealloc var targets []target for _, target := range allBuildTargets(build) { if !valid(target) { diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index 82491be0b..3d50cbc09 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -110,7 +110,7 @@ func doRun(ctx *context.Context, client client.Client) error { return ErrTooManyDarwin64Builds } - content, err := buildFormula(ctx, client, archives[0]) + content, err := buildFormula(ctx, archives[0]) if err != nil { return err } @@ -141,8 +141,8 @@ func doRun(ctx *context.Context, client client.Client) error { return client.CreateFile(ctx, ctx.Config.Brew.CommitAuthor, ctx.Config.Brew.GitHub, content, path, msg) } -func buildFormula(ctx *context.Context, client client.Client, artifact artifact.Artifact) (bytes.Buffer, error) { - data, err := dataFor(ctx, client, artifact) +func buildFormula(ctx *context.Context, artifact artifact.Artifact) (bytes.Buffer, error) { + data, err := dataFor(ctx, artifact) if err != nil { return bytes.Buffer{}, err } @@ -158,7 +158,7 @@ func doBuildFormula(data templateData) (out bytes.Buffer, err error) { return } -func dataFor(ctx *context.Context, client client.Client, artifact artifact.Artifact) (result templateData, err error) { +func dataFor(ctx *context.Context, artifact artifact.Artifact) (result templateData, err error) { sum, err := checksum.SHA256(artifact.Path) if err != nil { return diff --git a/pipeline/checksums/checksums.go b/pipeline/checksums/checksums.go index 9e19cf564..002d14fc4 100644 --- a/pipeline/checksums/checksums.go +++ b/pipeline/checksums/checksums.go @@ -63,7 +63,7 @@ func (Pipe) Run(ctx *context.Context) (err error) { defer func() { <-semaphore }() - return checksums(ctx, file, artifact) + return checksums(file, artifact) }) } ctx.Artifacts.Add(artifact.Artifact{ @@ -74,7 +74,7 @@ func (Pipe) Run(ctx *context.Context) (err error) { return g.Wait() } -func checksums(ctx *context.Context, file *os.File, artifact artifact.Artifact) error { +func checksums(file *os.File, artifact artifact.Artifact) error { log.WithField("file", artifact.Name).Info("checksumming") sha, err := checksum.SHA256(artifact.Path) if err != nil { diff --git a/pipeline/docker/docker.go b/pipeline/docker/docker.go index b47866894..bedfbf809 100644 --- a/pipeline/docker/docker.go +++ b/pipeline/docker/docker.go @@ -150,6 +150,7 @@ func tagName(ctx *context.Context, tagTemplate string) (string, error) { func process(ctx *context.Context, docker config.Docker, artifact artifact.Artifact, seed int) error { var root = filepath.Dir(artifact.Path) var dockerfile = filepath.Join(root, filepath.Base(docker.Dockerfile)) + fmt.Sprintf(".%d", seed) + // nolint:prealloc var images []string for _, tagTemplate := range docker.TagTemplates { tag, err := tagName(ctx, tagTemplate) diff --git a/pipeline/release/body.go b/pipeline/release/body.go index adab5cd29..081a1216e 100644 --- a/pipeline/release/body.go +++ b/pipeline/release/body.go @@ -27,6 +27,7 @@ func init() { func describeBody(ctx *context.Context) (bytes.Buffer, error) { var out bytes.Buffer + // nolint:prealloc var dockers []string for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() { dockers = append(dockers, a.Name) diff --git a/pipeline/scoop/scoop.go b/pipeline/scoop/scoop.go index 9106acff8..517fdce57 100644 --- a/pipeline/scoop/scoop.go +++ b/pipeline/scoop/scoop.go @@ -63,7 +63,7 @@ func doRun(ctx *context.Context, client client.Client) error { path := ctx.Config.ProjectName + ".json" - content, err := buildManifest(ctx, client, archives) + content, err := buildManifest(ctx, archives) if err != nil { return err } @@ -100,7 +100,7 @@ type Resource struct { Bin string `json:"bin"` // name of binary inside the archive } -func buildManifest(ctx *context.Context, client client.Client, artifacts []artifact.Artifact) (result bytes.Buffer, err error) { +func buildManifest(ctx *context.Context, artifacts []artifact.Artifact) (result bytes.Buffer, err error) { manifest := Manifest{ Version: ctx.Version, Architecture: make(map[string]Resource), diff --git a/pipeline/scoop/scoop_test.go b/pipeline/scoop/scoop_test.go index 03e6307d9..9a025827c 100644 --- a/pipeline/scoop/scoop_test.go +++ b/pipeline/scoop/scoop_test.go @@ -404,7 +404,7 @@ func Test_buildManifest(t *testing.T) { }, }, } - out, err := buildManifest(ctx, &DummyClient{}, []artifact.Artifact{ + out, err := buildManifest(ctx, []artifact.Artifact{ {Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64"}, {Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386"}, }) diff --git a/pipeline/sign/sign.go b/pipeline/sign/sign.go index 76015789e..8fe039d52 100644 --- a/pipeline/sign/sign.go +++ b/pipeline/sign/sign.go @@ -61,6 +61,7 @@ func (Pipe) Run(ctx *context.Context) error { } func sign(ctx *context.Context, artifacts []artifact.Artifact) error { + // nolint:prealloc var sigs []string for _, a := range artifacts { sig, err := signone(ctx, a) @@ -87,6 +88,7 @@ func signone(ctx *context.Context, artifact artifact.Artifact) (string, error) { } env["signature"] = expand(cfg.Signature, env) + // nolint:prealloc var args []string for _, a := range cfg.Args { args = append(args, expand(a, env))