Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
goddenrich committed Apr 9, 2024
1 parent 98b1e23 commit be08655
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.55.2
version: v1.57.2

22 changes: 4 additions & 18 deletions cmd/puku/puku.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"
"path/filepath"

Expand All @@ -21,19 +20,6 @@ import (
"github.com/please-build/puku/work"
)

type outputFormat string

// UnmarshalFlag implements the flags.Unmarshaler interface.
func (f *outputFormat) UnmarshalFlag(in string) error {
switch in {
case "json", "text":
*f = outputFormat(in)
default:
return fmt.Errorf("Flags error: Output format unrecognised")
}
return nil
}

var opts = struct {
Usage string
Verbosity clilogging.Verbosity `short:"v" long:"verbosity" description:"Verbosity of output (error, warning, notice, info, debug)" default:"info"`
Expand Down Expand Up @@ -99,7 +85,7 @@ var funcs = map[string]func(conf *config.Config, plzConf *please.Config, orignal
log.Fatalf("%v", err)
}
} else {
if err := sync.SyncToStdout(string(opts.Sync.Format), plzConf, g); err != nil {
if err := sync.SyncToStdout(opts.Sync.Format, plzConf, g); err != nil {
log.Fatalf("%v", err)
}
}
Expand All @@ -108,7 +94,7 @@ var funcs = map[string]func(conf *config.Config, plzConf *please.Config, orignal
"lint": func(conf *config.Config, plzConf *please.Config, orignalWD string) int {

Check warning on line 94 in cmd/puku/puku.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'conf' seems to be unused, consider removing or renaming it as _ (revive)

paths := work.MustExpandPaths(orignalWD, opts.Lint.Args.Paths)
if err := generate.UpdateToStdout(string(opts.Lint.Format), plzConf, paths...); err != nil {
if err := generate.UpdateToStdout(opts.Lint.Format, plzConf, paths...); err != nil {
log.Fatalf("%v", err)
}
return 0
Expand All @@ -135,7 +121,7 @@ var funcs = map[string]func(conf *config.Config, plzConf *please.Config, orignal
log.Fatalf("%v", err)
}
} else {
if err := migrate.MigrateToStdout(string(opts.Migrate.Format), conf, plzConf, opts.Migrate.UpdateGoMod, opts.Migrate.Args.Modules, paths); err != nil {
if err := migrate.MigrateToStdout(opts.Migrate.Format, conf, plzConf, opts.Migrate.UpdateGoMod, opts.Migrate.Args.Modules, paths); err != nil {
log.Fatalf("%v", err)
}
}
Expand All @@ -149,7 +135,7 @@ var funcs = map[string]func(conf *config.Config, plzConf *please.Config, orignal
log.Fatalf("%v", err)
}
} else {
if err := l.UpdateToStdout(string(opts.Licenses.Update.Format), paths); err != nil {
if err := l.UpdateToStdout(opts.Licenses.Update.Format, paths); err != nil {
log.Fatalf("%v", err)
}
}
Expand Down
8 changes: 6 additions & 2 deletions licences/licences.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ func getLicences(modPaths []string) (map[string][]string, error) {
}

func (l *Licenses) Update(paths []string) error {
l.update(paths)
if err := l.update(paths); err != nil {
return err
}
return l.graph.FormatFiles()
}

func (l *Licenses) UpdateToStdout(format string, paths []string) error {
l.update(paths)
if err := l.update(paths); err != nil {
return err
}
return l.graph.FormatFilesWithWriter(os.Stdout, format)
}

Expand Down
1 change: 0 additions & 1 deletion migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func Migrate(conf *config.Config, plzConf *please.Config, updateGoMod bool, modu
return err
}
return m.graph.FormatFiles()

}

func MigrateToStdout(format string, conf *config.Config, plzConf *please.Config, updateGoMod bool, modules, paths []string) error {

Check warning on line 53 in migrate/migrate.go

View workflow job for this annotation

GitHub Actions / lint

exported: func name will be used as migrate.MigrateToStdout by other packages, and that stutters; consider calling this ToStdout (revive)
Expand Down
1 change: 1 addition & 0 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func Sync(plzConf *please.Config, g *graph.Graph) error {
return s.graph.FormatFiles()
}

// SyncToStdout constructs the syncer and outputs the synced build file to stdout.
func SyncToStdout(format string, plzConf *please.Config, g *graph.Graph) error {

Check warning on line 47 in sync/sync.go

View workflow job for this annotation

GitHub Actions / lint

exported: func name will be used as sync.SyncToStdout by other packages, and that stutters; consider calling this ToStdout (revive)
s := newSyncer(plzConf, g)
if err := s.sync(); err != nil {
Expand Down

0 comments on commit be08655

Please sign in to comment.