Skip to content

Commit

Permalink
style: update golangci-lint to 1.56.2 (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
SevereCloud authored Feb 22, 2024
1 parent e150e61 commit fe8a1f5
Show file tree
Hide file tree
Showing 70 changed files with 2,343 additions and 2,315 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
go-version: 1.*
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.51
version: v1.56.2
23 changes: 23 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ linters:
- gocheckcompilerdirectives
- asasalint

- musttag

- gosmopolitan
- mirror
- tagalign

- gochecksumtype
- inamedparam
- perfsprint
- sloglint
- testifylint


# - musttag # TODO: need update golangci-lint
# - wrapcheck # TODO: v3 Fix
# - testpackage # TODO: Fix testpackage
Expand Down Expand Up @@ -106,6 +119,10 @@ linters:

# - ginkgolinter

# - zerologlint
# - protogetter
# - spancheck

# depricated
# - maligned
# - interfacer
Expand Down Expand Up @@ -138,3 +155,9 @@ issues:
text: "G307:"

exclude-use-default: false

linters-settings:
testifylint:
enable-all: true
disable:
- require-error # f func false positive
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func (vk *VK) DefaultHandler(method string, sliceParams ...Params) (Response, er
vk.lastTime = time.Now()
vk.rps = 0
}

vk.rps++

vk.mux.Unlock()
Expand Down
12 changes: 6 additions & 6 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func Test_FmtValue(t *testing.T) {
t.Helper()

got := api.FmtValue(value, 0)
assert.Equal(t, got, want)
assert.Equal(t, want, got)
}

f(nil, "")
Expand Down Expand Up @@ -301,11 +301,11 @@ func TestParams_methods(t *testing.T) {
p.CaptchaKey("text")
p.Confirm(true)

assert.Equal(t, p["lang"], 1)
assert.Equal(t, p["test_mode"], true)
assert.Equal(t, p["captcha_sid"], "text")
assert.Equal(t, p["captcha_key"], "text")
assert.Equal(t, p["confirm"], true)
assert.Equal(t, 1, p["lang"])
assert.Equal(t, true, p["test_mode"])
assert.Equal(t, "text", p["captcha_sid"])
assert.Equal(t, "text", p["captcha_key"])
assert.Equal(t, true, p["confirm"])
}

func TestContext(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestVK_AppsDeleteAppRequests(t *testing.T) {

res, err := vkUser.AppsDeleteAppRequests(nil)
noError(t, err)
assert.Equal(t, res, 1)
assert.Equal(t, 1, res)
}

func TestVK_AppsGet(t *testing.T) {
Expand Down
14 changes: 8 additions & 6 deletions api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import (
"github.com/SevereCloud/vksdk/v2/object"
)

const errorMessagePrefix = "api: "

// ErrorType is the type of an error.
type ErrorType int

// Error returns the message of a ErrorType.
func (e ErrorType) Error() string {
return fmt.Sprintf("api: error with code %d", e)
return fmt.Sprintf(errorMessagePrefix+"error with code %d", e)
}

// Error codes. See https://vk.com/dev/errors
Expand Down Expand Up @@ -850,7 +852,7 @@ type ErrorSubtype int

// Error returns the message of a ErrorSubtype.
func (e ErrorSubtype) Error() string {
return fmt.Sprintf("api: error with subcode %d", e)
return fmt.Sprintf(errorMessagePrefix+"error with subcode %d", e)
}

// Error struct VK.
Expand Down Expand Up @@ -917,7 +919,7 @@ type Error struct {

// Error returns the message of a Error.
func (e Error) Error() string {
return "api: " + e.Message
return errorMessagePrefix + e.Message
}

// Is unwraps its first argument sequentially looking for an error that matches
Expand Down Expand Up @@ -974,7 +976,7 @@ type UploadError struct {
// Error returns the message of a UploadError.
func (e UploadError) Error() string {
if e.Err != "" {
return "api: " + e.Err
return errorMessagePrefix + e.Err
}

return fmt.Sprintf("api: upload code %d", e.Code)
Expand All @@ -988,7 +990,7 @@ type AdsError struct {

// Error returns the message of a AdsError.
func (e AdsError) Error() string {
return "api: " + e.Desc
return errorMessagePrefix + e.Desc
}

// Is unwraps its first argument sequentially looking for an error that matches
Expand Down Expand Up @@ -1016,7 +1018,7 @@ type AuthSilentTokenError struct {

// Error returns the description of a AuthSilentTokenError.
func (e AuthSilentTokenError) Error() string {
return "api: " + e.Description
return errorMessagePrefix + e.Description
}

// Is unwraps its first argument sequentially looking for an error that matches
Expand Down
4 changes: 2 additions & 2 deletions api/oauth/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestNewGroupTokensFromJSON(t *testing.T) {
assert.EqualError(t, err, wantErr)
}

assert.Equal(t, token, wantToken)
assert.Equal(t, wantToken, token)
}

f([]byte("123"), nil, "json: cannot unmarshal number into Go value of type oauth.Error")
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestNewGroupTokensFromURL(t *testing.T) {
assert.EqualError(t, err, wantErr)
}

assert.Equal(t, token, wantToken)
assert.Equal(t, wantToken, token)
}

f(
Expand Down
4 changes: 2 additions & 2 deletions api/oauth/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestParseJSON(t *testing.T) {
assert.EqualError(t, err, wantErr)
}

assert.Equal(t, token, wantToken)
assert.Equal(t, wantToken, token)
}

f([]byte("123"), nil, "json: cannot unmarshal number into Go value of type oauth.Error")
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestParseURL(t *testing.T) {
assert.EqualError(t, err, wantErr)
}

assert.Equal(t, token, wantToken)
assert.Equal(t, wantToken, token)
}

f(
Expand Down
Loading

0 comments on commit fe8a1f5

Please sign in to comment.