Skip to content

Commit 004996f

Browse files
committed
chore: fixing linter errors
1 parent 0557593 commit 004996f

File tree

12 files changed

+58
-49
lines changed

12 files changed

+58
-49
lines changed

internal/error-handler/consts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ package errorHandler
22

33
import "github.com/thanhpk/randstr"
44

5-
var ErrorChannelName = randstr.Hex(16)
5+
var ErrorChannelName = randstr.Hex(16) //nolint:mnd

middleware/gin/error-handler/handler_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/gin-gonic/gin"
1010
"github.com/stretchr/testify/assert"
11+
1112
errorHandler "github.com/wisdom-oss/common-go/v3/middleware/gin/error-handler"
1213
)
1314

middleware/gin/jwt/jwt_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// nolint
12
package jwt
23

34
import (
@@ -23,12 +24,12 @@ func Test(t *testing.T) {
2324
key, err = jwk.FromRaw(jwkTestingKey)
2425
assert.NoError(t, err)
2526

26-
jwk.AssignKeyID(key)
27-
key.Set(jwk.KeyUsageKey, "sig")
28-
key.Set(jwk.AlgorithmKey, jwa.HS256)
27+
jwk.AssignKeyID(key) //nolint:errcheck
28+
key.Set(jwk.KeyUsageKey, "sig") //nolint:errcheck
29+
key.Set(jwk.AlgorithmKey, jwa.HS256) //nolint:errcheck
2930

3031
keySet = jwk.NewSet()
31-
keySet.AddKey(key)
32+
keySet.AddKey(key) //nolint:errcheck
3233

3334
v = &Validator{}
3435
err = v.Configure("test", keySet, nil)

middleware/gin/jwt/requirer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"slices"
66

77
"github.com/gin-gonic/gin"
8+
89
"github.com/wisdom-oss/common-go/v3/internal/jwt"
910
"github.com/wisdom-oss/common-go/v3/types"
1011
)

middleware/gin/jwt/requirer_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// nolint
12
package jwt
23

34
import (
@@ -9,12 +10,13 @@ import (
910

1011
"github.com/lestrrat-go/jwx/v2/jwa"
1112
"github.com/lestrrat-go/jwx/v2/jwt"
12-
jwt2 "github.com/lestrrat-go/jwx/v2/jwt"
1313
"github.com/stretchr/testify/assert"
1414
"github.com/thanhpk/randstr"
15-
"github.com/wisdom-oss/common-go/v3/types"
15+
16+
jwt2 "github.com/lestrrat-go/jwx/v2/jwt"
1617

1718
internal "github.com/wisdom-oss/common-go/v3/internal/jwt"
19+
"github.com/wisdom-oss/common-go/v3/types"
1820
)
1921

2022
const scopePrefix = "testing"

middleware/gin/jwt/validator_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// nolint
12
package jwt
23

34
import (
@@ -11,9 +12,11 @@ import (
1112

1213
"github.com/gin-gonic/gin"
1314
"github.com/lestrrat-go/jwx/v2/jwa"
14-
jwt2 "github.com/lestrrat-go/jwx/v2/jwt"
1515
"github.com/stretchr/testify/assert"
1616
"github.com/thanhpk/randstr"
17+
18+
jwt2 "github.com/lestrrat-go/jwx/v2/jwt"
19+
1720
"github.com/wisdom-oss/common-go/v3/internal/jwt"
1821
"github.com/wisdom-oss/common-go/v3/types"
1922
)

middleware/gin/recoverer/recoverer.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ package recoverer
22

33
import (
44
"fmt"
5+
"net/http"
56

67
"github.com/gin-gonic/gin"
8+
79
errorHandler "github.com/wisdom-oss/common-go/v3/middleware/stdlib/error-handler"
810
)
911

1012
func RecoveryHandler(c *gin.Context, err any) {
1113
response := errorHandler.Panic
1214
response.Errors = []error{fmt.Errorf("%v", err)}
1315
c.Header("Content-Type", "application/problem+json; charset=utf-8")
14-
c.AbortWithStatusJSON(500, response)
16+
c.AbortWithStatusJSON(http.StatusInternalServerError, response)
1517
}
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
package errorHandler
22

3-
import "github.com/wisdom-oss/common-go/v3/types"
3+
import (
4+
"net/http"
5+
6+
"github.com/wisdom-oss/common-go/v3/types"
7+
)
48

59
// Panic is the base types.ServiceError used if the ErrorHandler catches a panic
610
// during the handling of a request.
711
var Panic = &types.ServiceError{
812
Type: "https://pkg.go.dev/builtin#panic",
9-
Status: 500,
13+
Status: http.StatusInternalServerError,
1014
Title: "Internal Panic",
1115
Detail: "The service encountered a panic state during the handling of your request.",
1216
}
1317

14-
// InternalError is the base types.ServiceError if the ErrorHandler only
15-
// received objects implementing the Error() interface and no other errors were
16-
// raised during the handling of the request
18+
// raised during the handling of the request.
1719
var InternalError = &types.ServiceError{
1820
Type: "https://www.rfc-editor.org/rfc/rfc9110#section-15.6.1",
19-
Status: 500,
21+
Status: http.StatusInternalServerError,
2022
Title: "Internal Server Error",
2123
Detail: "The service encountered an internal error during the handling of your request",
2224
}
2325

24-
// InvalidTypeProvided is used in the case that an unsupported type has been
25-
// passed to the ErrorHandler
26+
// passed to the ErrorHandler.
2627
var InvalidTypeProvided = &types.ServiceError{
2728
Type: "https://www.rfc-editor.org/rfc/rfc9110#section-16.2",
28-
Status: 999,
29+
Status: 999, //nolint:mnd
2930
Title: "Invalid Error Supplied",
3031
Detail: "The content provided to the error handler is invalid",
3132
}
3233

33-
// NotFound is an error used in the NotFoundError handler
34+
// NotFound is an error used in the NotFoundError handler.
3435
var NotFound = &types.ServiceError{
3536
Type: "https://www.rfc-editor.org/rfc/rfc9110#section-15.5.5",
36-
Status: 404,
37+
Status: http.StatusNotFound,
3738
Title: "Route Not Found",
38-
Detail: "The requested route was not found. Please check your request and ensure that the route is correctly set up in the service",
39+
Detail: "The requested route was not found. Please check your request and ensure that the route is correctly set up in the service", //nolint:lll
3940
}

middleware/stdlib/error-handler/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func Handler(next http.Handler) http.Handler {
2222
for {
2323
p := recover()
2424
if p != nil {
25-
if p == http.ErrAbortHandler {
25+
if p == http.ErrAbortHandler { //nolint:errorlint
2626
panic(p)
2727
}
2828
panics = append(panics, p)

middleware/stdlib/error-handler/handler_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99

1010
"github.com/stretchr/testify/assert"
11+
1112
errorHandler "github.com/wisdom-oss/common-go/v3/middleware/stdlib/error-handler"
1213
"github.com/wisdom-oss/common-go/v3/types"
1314
)
@@ -53,7 +54,7 @@ func _recover_panic(t *testing.T) {
5354
r.ServeHTTP(rec, req)
5455
res := rec.Result()
5556

56-
assert.Equal(t, int(expectedError.Status), res.StatusCode)
57+
assert.Equal(t, int(expectedError.Status), res.StatusCode) //nolint:gosec
5758

5859
var receviedError types.ServiceError
5960
err := json.NewDecoder(res.Body).Decode(&receviedError)
@@ -79,7 +80,7 @@ func _native_error(t *testing.T) {
7980
r.ServeHTTP(rec, req)
8081
res := rec.Result()
8182

82-
assert.Equal(t, int(expectedError.Status), res.StatusCode)
83+
assert.Equal(t, int(expectedError.Status), res.StatusCode) //nolint:gosec
8384

8485
var receviedError types.ServiceError
8586
err := json.NewDecoder(res.Body).Decode(&receviedError)
@@ -105,7 +106,7 @@ func _service_error(t *testing.T) {
105106
r.ServeHTTP(rec, req)
106107
res := rec.Result()
107108

108-
assert.Equal(t, int(expectedError.Status), res.StatusCode)
109+
assert.Equal(t, int(expectedError.Status), res.StatusCode) //nolint:gosec
109110

110111
var receviedError types.ServiceError
111112
err := json.NewDecoder(res.Body).Decode(&receviedError)
@@ -130,7 +131,7 @@ func _invalid_type(t *testing.T) {
130131
r.ServeHTTP(rec, req)
131132
res := rec.Result()
132133

133-
assert.Equal(t, int(expectedError.Status), res.StatusCode)
134+
assert.Equal(t, int(expectedError.Status), res.StatusCode) //nolint:gosec
134135

135136
var receviedError types.ServiceError
136137
err := json.NewDecoder(res.Body).Decode(&receviedError)

0 commit comments

Comments
 (0)