Skip to content

Commit

Permalink
Update linter config and follow recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
kkyr committed Aug 4, 2021
1 parent e67d767 commit 689f912
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ linters:
- wsl
- gomnd
- testpackage
- wrapcheck
- nlreturn
- goerr113
- exhaustivestruct
- exhaustive
- cyclop
- funlen

issues:
exclude-rules:
Expand All @@ -16,6 +23,9 @@ issues:
- funlen
- scopelint
- gocognit
- paralleltest
- errorlint
- forcetypeassert
- path: doc\.go
linters:
- lll
3 changes: 1 addition & 2 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ func Test_fieldErrors_Error(t *testing.T) {

got := fe.Error()

want := "A: aerr, B: berr"
if want != got {
if want := "A: aerr, B: berr"; want != got {
t.Fatalf("want %q, got %q", want, got)
}

Expand Down
4 changes: 2 additions & 2 deletions fig.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (f *fig) processField(field *field) error {

if f.useEnv {
if err := f.setFromEnv(field.v, field.path()); err != nil {
return fmt.Errorf("unable to set from env: %v", err)
return fmt.Errorf("unable to set from env: %w", err)
}
}

Expand All @@ -218,7 +218,7 @@ func (f *fig) processField(field *field) error {

if field.setDefault && isZero(field.v) {
if err := f.setDefaultValue(field.v, field.defaultVal); err != nil {
return fmt.Errorf("unable to set default: %v", err)
return fmt.Errorf("unable to set default: %w", err)
}
}

Expand Down
11 changes: 3 additions & 8 deletions fig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,7 @@ func Test_fig_decodeMap(t *testing.T) {
} `fig:"server"`
}

err := fig.decodeMap(m, &cfg)
if err != nil {
if err := fig.decodeMap(m, &cfg); err != nil {
t.Fatalf("unexpected err: %v", err)
}

Expand Down Expand Up @@ -1026,12 +1025,7 @@ func Test_fig_setValue(t *testing.T) {
t.Fatalf("unexpected err: %v", err)
}

want, err := regexp.Compile("[a-z]+")
if err != nil {
t.Fatalf("error parsing time: %v", err)
}

if re.String() != want.String() {
if want := regexp.MustCompile("[a-z]+"); re.String() != want.String() {
t.Fatalf("want %v, got %v", want, re)
}
})
Expand Down Expand Up @@ -1159,6 +1153,7 @@ func Test_fig_setSlice(t *testing.T) {
}

func setenv(t *testing.T, key, value string) {
t.Helper()
if err := os.Setenv(key, value); err != nil {
t.Fatalf("os.Setenv() unexpected error: %v", err)
}
Expand Down

0 comments on commit 689f912

Please sign in to comment.