mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +02:00
fix: several linter issues
This commit is contained in:
parent
981d05a4a4
commit
874f53dacb
3
Makefile
3
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
|
||||
|
||||
|
@ -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 = "."
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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),
|
||||
|
@ -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"},
|
||||
})
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user