Skip to content

Commit

Permalink
ci: fixup sources to make new linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
shoenig committed Aug 25, 2024
1 parent 686177c commit 8965078
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 34 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/scripts/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ linters:
- errname
- errorlint
- exhaustive
- exportloopref
- gochecknoinits
- gocritic
- gofmt
- gosimple
Expand All @@ -25,7 +23,6 @@ linters:
- musttag
- nilnil
- noctx
- paralleltest
- perfsprint
- prealloc
- predeclared
Expand All @@ -39,8 +36,3 @@ linters:
- unused
- whitespace

linters-settings:
paralleltest:
ignore-missing-subtests: true
exhaustive:
default-signifies-exhaustive: true
13 changes: 6 additions & 7 deletions internal/commands/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package commands

import (
"flag"
"fmt"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -52,11 +51,11 @@ func newExtractor(ring keyring.Ring) Extractor {
// - any error
func (e *extractor) PreProcess(args []string) (string, *set.Set[string], *set.HashSet[*conceal.Text, int], error) {
if len(args) < 2 {
return "", nil, nil, fmt.Errorf("requires at least 2 arguments (namespace, <key,...>)")
return "", nil, nil, errors.New("requires at least 2 arguments (namespace, <key,...>)")
}
ns := args[0]
rm := set.New[string](4)
add := set.NewHashSet[*conceal.Text, int](8)
add := set.NewHashSet[*conceal.Text](8)
for i := 1; i < len(args); i++ {
s := args[i]
switch {
Expand All @@ -65,7 +64,7 @@ func (e *extractor) PreProcess(args []string) (string, *set.Set[string], *set.Ha
case strings.Contains(s, "="):
add.Insert(conceal.New(s))
default:
return "", nil, nil, fmt.Errorf("argument must start with '-' or contain '='")
return "", nil, nil, errors.New("argument must start with '-' or contain '='")
}
}
return ns, rm, add, nil
Expand All @@ -85,11 +84,11 @@ func (e *extractor) Namespace(vars *set.HashSet[*conceal.Text, int]) (*safe.Name
func (e *extractor) process(args []*conceal.Text) (map[string]safe.Encrypted, error) {
content := make(map[string]safe.Encrypted, len(args))
for _, kv := range args {
if key, secret, err := e.encryptEnvVar(kv); err != nil {
key, secret, err := e.encryptEnvVar(kv)
if err != nil {
return nil, err
} else {
content[key] = secret
}
content[key] = secret
}
return content, nil
}
Expand Down
4 changes: 3 additions & 1 deletion internal/commands/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func skipOS(t *testing.T) {
switch runtime.GOOS {
case "windows":
t.Skip("skipping on windows")
default:
// do not skip
}
}

Expand Down Expand Up @@ -155,7 +157,7 @@ func TestExecCmd_Execute_badCommand(t *testing.T) {

switch runtime.GOOS {
case "windows":
must.Eq(t, "envy: failed to exec: exec: \"/does/not/exist\": file does not exist\n", b.String())
must.Eq(t, "envy: failed to exec: exec: \"/does/not/exist\": file does not exist\n", b.String()) // nolint: dupword
default:
must.Eq(t, "envy: failed to exec: fork/exec /does/not/exist: no such file or directory\n", b.String())
}
Expand Down
10 changes: 5 additions & 5 deletions internal/commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ type listCmd struct {
box safe.Box
}

func (lc listCmd) Name() string {
func (listCmd) Name() string {
return listCmdName
}

func (lc listCmd) Synopsis() string {
func (listCmd) Synopsis() string {
return listCmdSynopsis
}

func (lc listCmd) Usage() string {
func (listCmd) Usage() string {
return listCmdUsage
}

func (lc listCmd) SetFlags(set *flag.FlagSet) {
func (listCmd) SetFlags(*flag.FlagSet) {
// no flags when listing namespaces
}

func (lc listCmd) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
func (lc listCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
if f.NArg() != 0 {
lc.writer.Errorf("list command expects no args")
return subcommands.ExitUsageError
Expand Down
10 changes: 5 additions & 5 deletions internal/commands/purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ type purgeCmd struct {
box safe.Box
}

func (pc purgeCmd) Name() string {
func (purgeCmd) Name() string {
return purgeCmdName
}

func (pc purgeCmd) Synopsis() string {
func (purgeCmd) Synopsis() string {
return purgeCmdSynopsis
}

func (pc purgeCmd) Usage() string {
func (purgeCmd) Usage() string {
return purgeCmdUsage
}

func (pc purgeCmd) SetFlags(_ *flag.FlagSet) {
func (purgeCmd) SetFlags(_ *flag.FlagSet) {
// no flags when purging namespace
}

func (pc purgeCmd) Execute(ctx context.Context, fs *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
func (pc purgeCmd) Execute(_ context.Context, fs *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
if fs.NArg() != 1 {
pc.writer.Errorf("expected one namespace argument")
return subcommands.ExitUsageError
Expand Down
10 changes: 5 additions & 5 deletions internal/commands/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ type setCmd struct {
box safe.Box
}

func (sc setCmd) Name() string {
func (setCmd) Name() string {
return setCmdName
}

func (sc setCmd) Synopsis() string {
func (setCmd) Synopsis() string {
return setCmdSynopsis
}

func (sc setCmd) Usage() string {
func (setCmd) Usage() string {
return setCmdUsage
}

func (sc setCmd) SetFlags(fs *flag.FlagSet) {
func (setCmd) SetFlags(*flag.FlagSet) {
}

func (sc setCmd) Execute(ctx context.Context, fs *flag.FlagSet, _ ...any) subcommands.ExitStatus {
func (sc setCmd) Execute(_ context.Context, fs *flag.FlagSet, _ ...any) subcommands.ExitStatus {
namespace, remove, add, err := sc.ex.PreProcess(fs.Args())
if err != nil {
sc.writer.Errorf("unable to parse args: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (sc showCmd) SetFlags(fs *flag.FlagSet) {
_ = fs.Bool(flagDecrypt, false, "decrypt will print secrets")
}

func (sc showCmd) Execute(ctx context.Context, fs *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
func (sc showCmd) Execute(_ context.Context, fs *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
decrypt := fsBool(fs, flagDecrypt)

if len(fs.Args()) != 1 {
Expand Down
3 changes: 1 addition & 2 deletions internal/keyring/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ func init() {

func setEnv(t *testing.T, key, value string) string {
previous := os.Getenv(key)
err := os.Setenv(key, value)
must.NoError(t, err)
t.Setenv(key, value)
return previous
}

Expand Down

0 comments on commit 8965078

Please sign in to comment.