Skip to content

Commit

Permalink
pin golangci-lint version to latest available, fix reported errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal committed May 9, 2024
1 parent c193d11 commit 2e45f0a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
version: v1.58

- name: install goveralls
run: go install github.com/mattn/goveralls@latest
Expand Down
17 changes: 6 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0.8
enable:
- shadow
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 100
goconst:
Expand All @@ -30,13 +27,12 @@ linters:
disable-all: true
enable:
- bodyclose
- megacheck
- revive
- govet
- unconvert
- megacheck
- staticcheck
- unused
- gas
- gosec
- misspell
- unparam
- typecheck
Expand All @@ -52,12 +48,11 @@ linters:
fast: false

run:
modules-download-mode: vendor
skip-dirs:
- vendor
concurrency: 4

issues:
exclude-dirs:
- vendor
exclude-rules:
- text: "weak cryptographic primitive"
linters:
Expand Down
38 changes: 19 additions & 19 deletions app/messager/messeger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func TestMessageProc_NewDefault(t *testing.T) {

func TestMessageProc_MakeMessage(t *testing.T) {
s := &EngineMock{
SaveFunc: func(msg *store.Message) error {
SaveFunc: func(*store.Message) error {
return nil
},
}
c := &CrypterMock{
EncryptFunc: func(req Request) ([]byte, error) {
EncryptFunc: func(Request) ([]byte, error) {
return []byte("encrypted blah"), nil
},
}
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestMessageProc_MakeMessage_Errors(t *testing.T) {
func TestMessageProc_MakeMessage_CrypterError(t *testing.T) {
s := &EngineMock{}
c := &CrypterMock{
EncryptFunc: func(req Request) ([]byte, error) {
EncryptFunc: func(Request) ([]byte, error) {
return nil, fmt.Errorf("crypter error")
},
}
Expand All @@ -113,7 +113,7 @@ func TestMessageProc_MakeMessage_CrypterError(t *testing.T) {

func TestMessageProc_LoadMessage_Err(t *testing.T) {
s := &EngineMock{
LoadFunc: func(key string) (*store.Message, error) {
LoadFunc: func(string) (*store.Message, error) {
return nil, fmt.Errorf("load error")
},
}
Expand All @@ -133,14 +133,14 @@ func TestMessageProc_LoadMessage_Err(t *testing.T) {

func TestMessageProc_LoadMessage_ExpiredErr(t *testing.T) {
s := &EngineMock{
LoadFunc: func(key string) (*store.Message, error) {
LoadFunc: func(string) (*store.Message, error) {
return &store.Message{
Data: []byte("data"),
PinHash: "some-hash",
Exp: time.Now().Add(-1 * time.Minute),
}, nil
},
RemoveFunc: func(key string) error {
RemoveFunc: func(string) error {
return nil
},
}
Expand All @@ -161,15 +161,15 @@ func TestMessageProc_LoadMessage_ExpiredErr(t *testing.T) {

func TestMessageProc_LoadMessage_BadPin(t *testing.T) {
s := &EngineMock{
LoadFunc: func(key string) (*store.Message, error) {
LoadFunc: func(string) (*store.Message, error) {
return &store.Message{
Data: []byte("data"),
PinHash: "some-hash",
Exp: time.Now().Add(1 * time.Minute),
}, nil
},

IncErrFunc: func(key string) (int, error) {
IncErrFunc: func(string) (int, error) {
return 0, fmt.Errorf("inc error")
},
}
Expand All @@ -190,18 +190,18 @@ func TestMessageProc_LoadMessage_BadPin(t *testing.T) {

func TestMessageProc_LoadMessage_BadPin_MaxAttempts(t *testing.T) {
s := &EngineMock{
LoadFunc: func(key string) (*store.Message, error) {
LoadFunc: func(string) (*store.Message, error) {
return &store.Message{
Data: []byte("data"),
PinHash: "some-hash",
Exp: time.Now().Add(1 * time.Minute),
}, nil
},
RemoveFunc: func(key string) error {
RemoveFunc: func(string) error {
return nil
},

IncErrFunc: func(key string) (int, error) {
IncErrFunc: func(string) (int, error) {
return 2, nil
},
}
Expand All @@ -228,10 +228,10 @@ func TestMessageProc_LoadMessage_BadPinAttempt(t *testing.T) {
}

s := &EngineMock{
LoadFunc: func(key string) (*store.Message, error) {
LoadFunc: func(string) (*store.Message, error) {
return msg, nil
},
IncErrFunc: func(key string) (int, error) {
IncErrFunc: func(string) (int, error) {
return 1, nil
},
}
Expand All @@ -254,20 +254,20 @@ func TestMessageProc_LoadMessage_BadPinAttempt(t *testing.T) {

func TestMessageProc_LoadMessage_DecryptError(t *testing.T) {
s := &EngineMock{
LoadFunc: func(key string) (*store.Message, error) {
LoadFunc: func(string) (*store.Message, error) {
return &store.Message{
Data: []byte("data"),
PinHash: "$2a$10$2d9OIFG2.zuVIiZznlpy/uJoTl4quQPbDSFnHbi0LuYDILuxHYkDu",
Exp: time.Now().Add(1 * time.Minute),
}, nil
},
RemoveFunc: func(key string) error {
RemoveFunc: func(string) error {
return nil
},
}

c := &CrypterMock{
DecryptFunc: func(req Request) ([]byte, error) {
DecryptFunc: func(Request) ([]byte, error) {
return nil, fmt.Errorf("decrypt error")
},
}
Expand All @@ -286,20 +286,20 @@ func TestMessageProc_LoadMessage_DecryptError(t *testing.T) {

func TestMessageProc_LoadMessage(t *testing.T) {
s := &EngineMock{
LoadFunc: func(key string) (*store.Message, error) {
LoadFunc: func(string) (*store.Message, error) {
return &store.Message{
Data: []byte("data"),
PinHash: "$2a$10$2d9OIFG2.zuVIiZznlpy/uJoTl4quQPbDSFnHbi0LuYDILuxHYkDu",
Exp: time.Now().Add(1 * time.Minute),
}, nil
},
RemoveFunc: func(key string) error {
RemoveFunc: func(string) error {
return nil
},
}

c := &CrypterMock{
DecryptFunc: func(req Request) ([]byte, error) {
DecryptFunc: func(Request) ([]byte, error) {
return []byte("decrypted blah"), nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion app/server/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func Logger(l log.L, flags ...LoggerFlag) func(http.Handler) http.Handler {
result = string(content)
r.Body = io.NopCloser(bytes.NewReader(content))

if len(result) > 0 {
if result != "" {
result = strings.Replace(result, "\n", " ", -1)
result = reMultWhtsp.ReplaceAllString(result, " ")
}
Expand Down
4 changes: 2 additions & 2 deletions app/server/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestLogger(t *testing.T) {
rr := httptest.NewRecorder()
out := bytes.Buffer{}
l := lgr.New(lgr.Out(&out))
testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testHandler := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
t.Logf("%v", r)
})

Expand All @@ -36,7 +36,7 @@ func TestLoggerMasking(t *testing.T) {
rr := httptest.NewRecorder()
out := bytes.Buffer{}
l := lgr.New(lgr.Out(&out))
testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testHandler := http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
t.Logf("%v", r)
})

Expand Down
Loading

0 comments on commit 2e45f0a

Please sign in to comment.