Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bumps golangci-linter version to 1.44 and fixes newley reported issues #47

Merged
merged 1 commit into from Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Expand Up @@ -16,6 +16,7 @@ issues:
- paralleltest
- testpackage
- goerr113
- varnamelen
- path: github/client
linters:
- gosec
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -39,7 +39,7 @@ deps:
@ echo "-> Installing project dependencies..."
@ GO111MODULE=off go get -u github.com/myitcv/gobin
@ $(GOBIN)/gobin golang.org/x/lint/golint
@ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOBIN) v1.42.1
@ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOBIN) v1.44.0
@ echo "-> Done."

## Formats code and fixes as many as possible linter errors
Expand Down
18 changes: 9 additions & 9 deletions assert/error_messages.go
Expand Up @@ -16,20 +16,20 @@ func shouldBeEqual(actual types.Assertable, expected interface{}) string {

if !skipDetailedDiff {
diffs, _ := diff.Diff(expected, actual.Value())
for _, d := range diffs {
if len(d.Path) == 0 {
for _, diff := range diffs {
if len(diff.Path) == 0 {
continue
}
switch d.Type {
switch diff.Type {
case "delete":
path := strings.Join(d.Path, ":")
diffMessage.WriteString(fmt.Sprintf("actual value of %+v is expected but missing from %s\n", d.To, path))
path := strings.Join(diff.Path, ":")
diffMessage.WriteString(fmt.Sprintf("actual value of %+v is expected but missing from %s\n", diff.To, path))
case "create":
path := strings.Join(d.Path, ":")
diffMessage.WriteString(fmt.Sprintf("actual value of %+v is not expected in %s\n", d.To, path))
path := strings.Join(diff.Path, ":")
diffMessage.WriteString(fmt.Sprintf("actual value of %+v is not expected in %s\n", diff.To, path))
case "update":
path := strings.Join(d.Path, ":")
diffMessage.WriteString(fmt.Sprintf("actual value of %+v is different in %s from %+v\n", d.To, path, d.From))
path := strings.Join(diff.Path, ":")
diffMessage.WriteString(fmt.Sprintf("actual value of %+v is different in %s from %+v\n", diff.To, path, diff.From))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/types/time_value.go
Expand Up @@ -62,7 +62,7 @@ func (t TimeValue) isBefore(expected TimeValue) bool {
func NewTimeValue(value interface{}) TimeValue {
switch v := value.(type) {
case time.Time:
return TimeValue{value: value.(time.Time)}
return TimeValue{value: v}
default:
panic(fmt.Sprintf("expected time.Time value type but got %T type", v))
}
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/values/any_value.go
Expand Up @@ -91,12 +91,12 @@ func (s AnyValue) HasTypeOf(t reflect.Type) bool {

// NewAnyValue creates and returns an AnyValue struct initialed with the given value.
func NewAnyValue(value interface{}) AnyValue {
switch v := value.(type) {
switch cValue := value.(type) {
case nil:
return AnyValue{value: v}
return AnyValue{value: cValue}
case interface{}:
return AnyValue{value: v}
return AnyValue{value: cValue}
default:
panic(fmt.Sprintf("expected interface{} value type but got %T type", v))
panic(fmt.Sprintf("expected interface{} value type but got %T type", cValue))
}
}
2 changes: 1 addition & 1 deletion internal/pkg/values/duration_value.go
Expand Up @@ -47,7 +47,7 @@ func (d DurationValue) isShorter(expected DurationValue) bool {
func NewDurationValue(value interface{}) DurationValue {
switch v := value.(type) {
case time.Duration:
return DurationValue{value: value.(time.Duration)}
return DurationValue{value: v}
default:
panic(fmt.Sprintf("expected time.Duration value type but got %T type", v))
}
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/values/error_value.go
Expand Up @@ -18,12 +18,12 @@ func (v ErrorValue) Value() interface{} {

// NewErrorValue creates and returns a ErrorValue struct initialed with the given value.
func NewErrorValue(value interface{}) ErrorValue {
switch v := value.(type) {
switch cValue := value.(type) {
case nil:
return ErrorValue{}
case error:
return ErrorValue{value: v}
return ErrorValue{value: cValue}
default:
panic(fmt.Sprintf("expected error value type but got %T type", v))
panic(fmt.Sprintf("expected error value type but got %T type", cValue))
}
}
14 changes: 7 additions & 7 deletions internal/pkg/values/int_value.go
Expand Up @@ -53,18 +53,18 @@ func (i IntValue) equals(expected IntValue) bool {

// NewIntValue creates and returns an IntValue struct initialed with the given value.
func NewIntValue(value interface{}) IntValue {
switch v := value.(type) {
switch cValue := value.(type) {
case int:
return IntValue{value: value.(int)}
return IntValue{value: cValue}
case int8:
return IntValue{value: int(value.(int8))}
return IntValue{value: int(cValue)}
case int16:
return IntValue{value: int(value.(int16))}
return IntValue{value: int(cValue)}
case int32:
return IntValue{value: int(value.(int32))}
return IntValue{value: int(cValue)}
case int64:
return IntValue{value: int(value.(int64))}
return IntValue{value: int(cValue)}
default:
panic(fmt.Sprintf("expected int value type but got %T type", v))
panic(fmt.Sprintf("expected int value type but got %T type", cValue))
}
}
14 changes: 7 additions & 7 deletions internal/pkg/values/uint_value.go
Expand Up @@ -53,18 +53,18 @@ func (i UIntValue) equals(expected UIntValue) bool {

// NewUIntValue creates and returns a UIntValue struct initialed with the given value.
func NewUIntValue(value interface{}) UIntValue {
switch v := value.(type) {
switch cValue := value.(type) {
case uint:
return UIntValue{value: value.(uint)}
return UIntValue{value: cValue}
case uint8:
return UIntValue{value: uint(value.(uint8))}
return UIntValue{value: uint(cValue)}
case uint16:
return UIntValue{value: uint(value.(uint16))}
return UIntValue{value: uint(cValue)}
case uint32:
return UIntValue{value: uint(value.(uint32))}
return UIntValue{value: uint(cValue)}
case uint64:
return UIntValue{value: uint(value.(uint64))}
return UIntValue{value: uint(cValue)}
default:
panic(fmt.Sprintf("expected uint value type but got %T type", v))
panic(fmt.Sprintf("expected uint value type but got %T type", cValue))
}
}