Skip to content

Commit

Permalink
Add staticcheck to CI flow
Browse files Browse the repository at this point in the history
  • Loading branch information
aldas committed Nov 21, 2022
1 parent 3c4d3b3 commit a0c2115
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/echo.yml
Expand Up @@ -44,13 +44,19 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: Install Dependencies
run: go install golang.org/x/lint/golint@latest

- name: Run Tests
run: go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./...

- name: Install dependencies for checks
run: |
golint -set_exit_status ./...
go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
go install golang.org/x/lint/golint@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Run golint
run: golint -set_exit_status ./...

- name: Run staticcheck
run: staticcheck ./...

- name: Upload coverage to Codecov
if: success() && matrix.go == 1.19 && matrix.os == 'ubuntu-latest'
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Expand Up @@ -10,8 +10,10 @@ check: lint vet race ## Check project

init:
@go install golang.org/x/lint/golint@latest
@go install honnef.co/go/tools/cmd/staticcheck@latest

lint: ## Lint the files
@staticcheck ${PKG_LIST}
@golint -set_exit_status ${PKG_LIST}

vet: ## Vet the files
Expand Down
2 changes: 1 addition & 1 deletion middleware/jwt.go
Expand Up @@ -262,7 +262,7 @@ func JWTWithConfig(config JWTConfig) echo.MiddlewareFunc {
}

func (config *JWTConfig) defaultParseToken(auth string, c echo.Context) (interface{}, error) {
token := new(jwt.Token)
var token *jwt.Token
var err error
// Issue #647, #656
if _, ok := config.Claims.(jwt.MapClaims); ok {
Expand Down
3 changes: 1 addition & 2 deletions middleware/proxy_test.go
Expand Up @@ -384,10 +384,9 @@ func TestProxyError(t *testing.T) {
e := echo.New()
e.Use(Proxy(rb))
req := httptest.NewRequest(http.MethodGet, "/", nil)
rec := httptest.NewRecorder()

// Remote unreachable
rec = httptest.NewRecorder()
rec := httptest.NewRecorder()
req.URL.Path = "/api/users"
e.ServeHTTP(rec, req)
assert.Equal(t, "/api/users", req.URL.Path)
Expand Down
6 changes: 3 additions & 3 deletions middleware/timeout_test.go
Expand Up @@ -129,7 +129,7 @@ func TestTimeoutOnTimeoutRouteErrorHandler(t *testing.T) {
e := echo.New()
c := e.NewContext(req, rec)

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

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

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

0 comments on commit a0c2115

Please sign in to comment.