1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-24 08:22:21 +02:00

Add staticcheck to CI flow

This commit is contained in:
toimtoimtoim 2022-11-21 16:05:30 +02:00 committed by Martti T
parent 3c4d3b3083
commit a0c211542c
5 changed files with 18 additions and 11 deletions

View File

@ -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'

View File

@ -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

View File

@ -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 {

View File

@ -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)

View File

@ -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")
@ -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
@ -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!")