Skip to content

Commit a0c2115

Browse files
committed
Add staticcheck to CI flow
1 parent 3c4d3b3 commit a0c2115

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

.github/workflows/echo.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,19 @@ jobs:
4444
with:
4545
go-version: ${{ matrix.go }}
4646

47-
- name: Install Dependencies
48-
run: go install golang.org/x/lint/golint@latest
49-
5047
- name: Run Tests
48+
run: go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
49+
50+
- name: Install dependencies for checks
5151
run: |
52-
golint -set_exit_status ./...
53-
go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
52+
go install golang.org/x/lint/golint@latest
53+
go install honnef.co/go/tools/cmd/staticcheck@latest
54+
55+
- name: Run golint
56+
run: golint -set_exit_status ./...
57+
58+
- name: Run staticcheck
59+
run: staticcheck ./...
5460

5561
- name: Upload coverage to Codecov
5662
if: success() && matrix.go == 1.19 && matrix.os == 'ubuntu-latest'

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ check: lint vet race ## Check project
1010

1111
init:
1212
@go install golang.org/x/lint/golint@latest
13+
@go install honnef.co/go/tools/cmd/staticcheck@latest
1314

1415
lint: ## Lint the files
16+
@staticcheck ${PKG_LIST}
1517
@golint -set_exit_status ${PKG_LIST}
1618

1719
vet: ## Vet the files

middleware/jwt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func JWTWithConfig(config JWTConfig) echo.MiddlewareFunc {
262262
}
263263

264264
func (config *JWTConfig) defaultParseToken(auth string, c echo.Context) (interface{}, error) {
265-
token := new(jwt.Token)
265+
var token *jwt.Token
266266
var err error
267267
// Issue #647, #656
268268
if _, ok := config.Claims.(jwt.MapClaims); ok {

middleware/proxy_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,9 @@ func TestProxyError(t *testing.T) {
384384
e := echo.New()
385385
e.Use(Proxy(rb))
386386
req := httptest.NewRequest(http.MethodGet, "/", nil)
387-
rec := httptest.NewRecorder()
388387

389388
// Remote unreachable
390-
rec = httptest.NewRecorder()
389+
rec := httptest.NewRecorder()
391390
req.URL.Path = "/api/users"
392391
e.ServeHTTP(rec, req)
393392
assert.Equal(t, "/api/users", req.URL.Path)

middleware/timeout_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestTimeoutOnTimeoutRouteErrorHandler(t *testing.T) {
129129
e := echo.New()
130130
c := e.NewContext(req, rec)
131131

132-
stopChan := make(chan struct{}, 0)
132+
stopChan := make(chan struct{})
133133
err := m(func(c echo.Context) error {
134134
<-stopChan
135135
return errors.New("error in route after timeout")
@@ -245,7 +245,7 @@ func TestTimeoutWithErrorMessage(t *testing.T) {
245245
e := echo.New()
246246
c := e.NewContext(req, rec)
247247

248-
stopChan := make(chan struct{}, 0)
248+
stopChan := make(chan struct{})
249249
err := m(func(c echo.Context) error {
250250
// NOTE: when difference between timeout duration and handler execution time is almost the same (in range of 100microseconds)
251251
// the result of timeout does not seem to be reliable - could respond timeout, could respond handler output
@@ -275,7 +275,7 @@ func TestTimeoutWithDefaultErrorMessage(t *testing.T) {
275275
e := echo.New()
276276
c := e.NewContext(req, rec)
277277

278-
stopChan := make(chan struct{}, 0)
278+
stopChan := make(chan struct{})
279279
err := m(func(c echo.Context) error {
280280
<-stopChan
281281
return c.String(http.StatusOK, "Hello, World!")

0 commit comments

Comments
 (0)