mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-05 13:15:26 +02:00
refactor: remove empty lines, fix //nolint (#5235)
The PR formats code by removing redundant empty lines and fixes `//nolint` directives. Additionally, this PR adds two more rules to the `revive` configuration: `empty-lines` and `comment-spacings`. Removing unnecessary empty lines helps to keep the codebase clean and concise. This issue is identified by the `revive.empty-lines` rule. In the `//nolint` directive, there must be no spaces between `:` and the linter name: `//nolint:gosec`. See ["Nolint Directive"](https://golangci-lint.run/usage/false-positives/#nolint-directive). This issue is identified by the `revive.comment-spacings` rule. Note that it's not possible to add just a few additional rules to the `revive.enable` list. We need to specify all: default rules plus additional rules. See the detailed explanation [here](https://github.com/prometheus/prometheus/pull/13068).
This commit is contained in:
parent
b269cc9229
commit
12155a336b
@ -42,6 +42,34 @@ linters-settings:
|
||||
deny:
|
||||
- pkg: "github.com/pkg/errors"
|
||||
desc: "use stdlib instead"
|
||||
revive:
|
||||
enable-all-rules: false
|
||||
rules:
|
||||
- name: blank-imports
|
||||
- name: context-as-argument
|
||||
- name: context-keys-type
|
||||
- name: comment-spacings
|
||||
- name: dot-imports
|
||||
- name: empty-block
|
||||
- name: empty-lines
|
||||
- name: error-naming
|
||||
- name: error-return
|
||||
- name: error-strings
|
||||
- name: errorf
|
||||
- name: exported
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
- name: package-comments
|
||||
- name: range
|
||||
- name: receiver-naming
|
||||
- name: redefines-builtin-id
|
||||
- name: superfluous-else
|
||||
- name: time-naming
|
||||
- name: unexported-return
|
||||
- name: unreachable-code
|
||||
- name: unused-parameter
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
testifylint:
|
||||
enable-all: true
|
||||
disable:
|
||||
|
@ -149,7 +149,6 @@ func (c *giteaClient) CreateFile(
|
||||
WithError(err).
|
||||
Warn("error checking for default branch, using master")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fileOptions := gitea.FileOptions{
|
||||
|
@ -269,7 +269,6 @@ func TestRunPipe(t *testing.T) {
|
||||
header := tarInfo(t, filepath.Join(dist, name), expectBin)
|
||||
require.Equal(t, "root", header.Uname)
|
||||
require.Equal(t, "root", header.Gname)
|
||||
|
||||
}
|
||||
}
|
||||
if format == "zip" {
|
||||
|
@ -178,7 +178,7 @@ func doRun(ctx *context.Context, aur config.AUR, cl client.ReleaseURLTemplater)
|
||||
return fmt.Errorf("failed to write %s: %w", info.kind, err)
|
||||
}
|
||||
log.WithField("file", path).Info("writing")
|
||||
if err := os.WriteFile(path, []byte(pkgContent), 0o644); err != nil { //nolint: gosec
|
||||
if err := os.WriteFile(path, []byte(pkgContent), 0o644); err != nil { //nolint:gosec
|
||||
return fmt.Errorf("failed to write %s: %w", info.kind, err)
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ func doRun(ctx *context.Context, brew config.Homebrew, cl client.ReleaseURLTempl
|
||||
}
|
||||
|
||||
log.WithField("formula", path).Info("writing")
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil { //nolint: gosec
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil { //nolint:gosec
|
||||
return fmt.Errorf("failed to write brew formula: %w", err)
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
|
||||
path := filepath.Join(ctx.Config.Dist, "CHANGELOG.md")
|
||||
log.WithField("path", path).Debug("writing changelog")
|
||||
return os.WriteFile(path, []byte(ctx.ReleaseNotes), 0o644) //nolint: gosec
|
||||
return os.WriteFile(path, []byte(ctx.ReleaseNotes), 0o644) //nolint:gosec
|
||||
}
|
||||
|
||||
type changelogGroup struct {
|
||||
|
@ -22,5 +22,5 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
return err
|
||||
}
|
||||
log.WithField("path", path).Debug("writing effective configuration")
|
||||
return os.WriteFile(path, bts, 0o644) //nolint: gosec
|
||||
return os.WriteFile(path, bts, 0o644) //nolint:gosec
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ func doRun(ctx *context.Context, krew config.Krew, cl client.ReleaseURLTemplater
|
||||
return err
|
||||
}
|
||||
log.WithField("manifest", yamlPath).Info("writing")
|
||||
if err := os.WriteFile(yamlPath, []byte("# This file was generated by GoReleaser. DO NOT EDIT.\n"+content), 0o644); err != nil { //nolint: gosec
|
||||
if err := os.WriteFile(yamlPath, []byte("# This file was generated by GoReleaser. DO NOT EDIT.\n"+content), 0o644); err != nil { //nolint:gosec
|
||||
return fmt.Errorf("failed to write krew manifest: %w", err)
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,6 @@ func TestRunPipe(t *testing.T) {
|
||||
f, err := os.Create(name)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, f.Close())
|
||||
|
||||
}
|
||||
libPrefix := `/usr/lib
|
||||
{{- if eq .Arch "amd64" }}{{if eq .Format "rpm"}}_rpm{{end}}64{{- end -}}
|
||||
|
@ -174,7 +174,7 @@ func (p Pipe) doRun(ctx *context.Context, nix config.Nix, cl client.ReleaseURLTe
|
||||
}
|
||||
|
||||
log.WithField("nixpkg", path).Info("writing")
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil { //nolint: gosec
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil { //nolint:gosec
|
||||
return fmt.Errorf("failed to write nixpkg: %w", err)
|
||||
}
|
||||
|
||||
|
@ -550,7 +550,6 @@ func TestRunPipe(t *testing.T) {
|
||||
err := bpipe.Default(ctx)
|
||||
require.ErrorAs(t, err, &tt.expectDefaultErrorIs)
|
||||
return
|
||||
|
||||
}
|
||||
require.NoError(t, bpipe.Default(ctx))
|
||||
|
||||
|
@ -139,7 +139,6 @@ func signAndNotarize(ctx *context.Context, cfg config.MacOSSignNotarize) error {
|
||||
default:
|
||||
log.WithField("binary", bin.Path).Info("notarize still pending")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if err := binaries.Refresh(); err != nil {
|
||||
|
@ -239,7 +239,6 @@ func catalogArtifact(ctx *context.Context, cfg config.SBOM, a *artifact.Artifact
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(artifacts) == 0 {
|
||||
|
@ -408,7 +408,7 @@ func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries [
|
||||
}
|
||||
|
||||
log.WithField("file", file).Debugf("writing metadata file")
|
||||
if err = os.WriteFile(file, out, 0o644); err != nil { //nolint: gosec
|
||||
if err = os.WriteFile(file, out, 0o644); err != nil { //nolint:gosec
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,6 @@ func TestRun(t *testing.T) {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,7 +228,6 @@ func TestFindBinaries(t *testing.T) {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ func createYAML(ctx *context.Context, winget config.Winget, in any, tp artifact.
|
||||
generatedHeader,
|
||||
langserverLineFor(tp),
|
||||
string(versionContent),
|
||||
}, "\n")), 0o644); err != nil { //nolint: gosec
|
||||
}, "\n")), 0o644); err != nil { //nolint:gosec
|
||||
return fmt.Errorf("failed to write winget version: %w", err)
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,6 @@ func Copy(source *os.File, target io.Writer) (Archive, error) {
|
||||
}
|
||||
w := New(target)
|
||||
for _, zf := range r.File {
|
||||
|
||||
w.files[zf.Name] = true
|
||||
hdr := zip.FileHeader{
|
||||
Name: zf.Name,
|
||||
|
Loading…
x
Reference in New Issue
Block a user