code cleanup, new linter conf

This commit is contained in:
Giovanni Harting 2023-06-14 15:56:26 +02:00
parent 4b75e0f8a7
commit 442b793524
6 changed files with 46 additions and 38 deletions

View File

@ -47,31 +47,41 @@ linters-settings:
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
tagliatelle:
case:
use-field-name: true
rules:
# Any struct tag type can be used.
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `upperSnake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`.
json: snake
yaml: snake
xml: camel
linters:
disable-all: true
enable:
- bodyclose
- dogsled
- dupl
- errcheck
- exportloopref
- gochecknoinits
- gocritic
- gofmt
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- lll
- misspell
- noctx
- nolintlint
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
enable-all: true
disable:
- gochecknoglobals
- depguard
- gci
- gofumpt
- goimports
- varnamelen
- funlen
- cyclop
- wsl
- nosnakecase
- nlreturn
- godot
- nestif
- wrapcheck
- gocognit
- gocyclo
- maintidx
- nonamedreturns
- exhaustivestruct
- exhaustruct
- forcetypeassert
- godox
# remove for new projects
- errname
- goerr113

View File

@ -30,7 +30,7 @@ type BuildManager struct {
queueSignal chan struct{}
}
func (b *BuildManager) buildQueue(queue []*ProtoPackage, ctx context.Context) error {
func (b *BuildManager) buildQueue(ctx context.Context, queue []*ProtoPackage) error {
var (
doneQ []*ProtoPackage
doneQLock = new(sync.RWMutex)
@ -281,7 +281,7 @@ func (b *BuildManager) htmlWorker(ctx context.Context) {
db.DBPackage.Query().GroupBy(dbpackage.FieldStatus).Aggregate(ent.Count()).ScanX(ctx, &v)
for _, c := range v {
switch c.Status {
switch c.Status { //nolint:exhaustive
case dbpackage.StatusFailed:
gen.Failed = c.Count
case dbpackage.StatusSkipped:
@ -294,7 +294,7 @@ func (b *BuildManager) htmlWorker(ctx context.Context) {
}
var v2 []struct {
Status dbpackage.Lto `json:"lto"`
Status dbpackage.Lto `json:"lto"` //nolint:tagliatelle
Count int `json:"count"`
}
@ -522,7 +522,7 @@ func (b *BuildManager) syncWorker(ctx context.Context) error {
log.Errorf("error building queue: %v", err)
} else {
log.Debugf("build-queue with %d items", len(queue))
err = b.buildQueue(queue, ctx)
err = b.buildQueue(ctx, queue)
if err != nil {
return err
}

View File

@ -85,7 +85,7 @@ func (pkg Package) DBPackageIsolated(march string, repo dbpackage.Repository, db
)
}).Only(context.Background())
if ent.IsNotFound(err) {
log.Debugf("Not found in database: %s", pkg.Name())
log.Debugf("not found in database: %s", pkg.Name())
return nil, err
} else if err != nil {
return nil, err

View File

@ -69,9 +69,8 @@ func (p *ProtoPackage) isEligible(ctx context.Context) bool {
p.DBPackage = p.DBPackage.Update().SetUpdated(time.Now()).SetVersion(p.Version).SetStatus(p.DBPackage.Status).
SetSkipReason(p.DBPackage.SkipReason).SetTagRev(p.State.TagRev).SaveX(ctx)
return false
} else {
p.DBPackage = p.DBPackage.Update().SetUpdated(time.Now()).SetVersion(p.Version).SaveX(ctx)
}
p.DBPackage = p.DBPackage.Update().SetUpdated(time.Now()).SetVersion(p.Version).SaveX(ctx)
if Contains(conf.Blacklist.LTO, p.Pkgbase) && p.DBPackage.Lto != dbpackage.LtoDisabled {
p.DBPackage = p.DBPackage.Update().SetLto(dbpackage.LtoDisabled).SaveX(ctx)
@ -359,8 +358,7 @@ func (p *ProtoPackage) setupBuildDir() (string, error) {
}
func (p *ProtoPackage) repoVersion() (string, error) {
err := p.findPkgFiles()
if err != nil {
if err := p.findPkgFiles(); err != nil {
return "", err
}
@ -694,7 +692,7 @@ func (p *ProtoPackage) isMirrorLatest(h *alpm.Handle) (latest bool, foundPkg alp
return false, nil, "", UnableToSatisfyError{err}
}
svn2gitVer, err := (&ProtoPackage{
svn2gitVer, err := (&ProtoPackage{ //nolint:exhaustruct,exhaustivestruct
Pkgbase: pkg.Base(),
March: p.March,
}).GitVersion(h)

View File

@ -51,7 +51,7 @@ package() {
# vim:set sw=2 et:
`
func TestIncreasePkgRel(t *testing.T) {
func TestIncreasePkgRel(t *testing.T) { //nolint:paralleltest
pkgbuild, err := os.CreateTemp("", "")
if err != nil {
t.Fatal("Unable to setup temp. PKGBUILD")

View File

@ -112,7 +112,7 @@ func updateLastUpdated() error {
}
func statusID2string(s dbpackage.Status) string {
switch s {
switch s { //nolint:exhaustive
case dbpackage.StatusSkipped:
return conf.Status.Class.Skipped
case dbpackage.StatusQueued: