resolve linter issues

This commit is contained in:
David Christofas
2021-02-26 14:24:25 +01:00
parent 690399008d
commit cfcd4b5992
6 changed files with 29 additions and 49 deletions

View File

@@ -1,33 +0,0 @@
issues:
exclude-rules:
- path: pkg/middleware/account_uuid.go
text: "SA4006:"
linters:
- staticcheck
- path: pkg/proxy/proxy_integration_test.go
linters:
- bodyclose
linters:
enable:
- bodyclose
- deadcode
- gosimple
- govet
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- depguard
- golint
- unconvert
# - scopelint
- maligned
- misspell
- prealloc
#- gosec
disable:
- errcheck
- ineffassign
- scopelint

View File

@@ -49,21 +49,27 @@ func New() *Metrics {
}, []string{"versions"}),
}
prometheus.Register(
mustNotFail(prometheus.Register(
m.Counter,
)
))
prometheus.Register(
mustNotFail(prometheus.Register(
m.Latency,
)
))
prometheus.Register(
mustNotFail(prometheus.Register(
m.Duration,
)
))
prometheus.Register(
mustNotFail(prometheus.Register(
m.BuildInfo,
)
))
return m
}
func mustNotFail(err error) {
if err != nil {
panic(err)
}
}

View File

@@ -112,7 +112,7 @@ func (m oidcAuth) getClaims(token string, req *http.Request) (claims oidc.Standa
return
}
var ok = false
var ok bool
if claims, ok = hit.V.(oidc.StandardClaims); !ok {
status = http.StatusInternalServerError
return

View File

@@ -136,16 +136,17 @@ func TestProxyIntegration(t *testing.T) {
rr := httptest.NewRecorder()
rp.ServeHTTP(rr, tc.input)
rsp := rr.Result()
if rr.Result().StatusCode != 200 {
t.Errorf("Expected status 200 from proxy-response got %v", rr.Result().StatusCode)
if rsp.StatusCode != 200 {
t.Errorf("Expected status 200 from proxy-response got %v", rsp.StatusCode)
}
resultBody, err := ioutil.ReadAll(rr.Result().Body)
resultBody, err := ioutil.ReadAll(rsp.Body)
if err != nil {
t.Fatal("Error reading result body")
}
if err = rr.Result().Body.Close(); err != nil {
if err = rsp.Body.Close(); err != nil {
t.Fatal("Error closing result body")
}

View File

@@ -33,7 +33,9 @@ func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
// TODO(tboerger): check if services are up and running
io.WriteString(w, http.StatusText(http.StatusOK))
if _, err := io.WriteString(w, http.StatusText(http.StatusOK)); err != nil {
panic(err)
}
}
}
@@ -45,6 +47,8 @@ func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
// TODO(tboerger): check if services are up and running
io.WriteString(w, http.StatusText(http.StatusOK))
if _, err := io.WriteString(w, http.StatusText(http.StatusOK)); err != nil {
panic(err)
}
}
}

View File

@@ -59,7 +59,9 @@ func Server(opts ...Option) (svc.Service, error) {
svc.Flags(options.Flags...),
)
micro.RegisterHandler(service.Server(), chain)
if err := micro.RegisterHandler(service.Server(), chain); err != nil {
return svc.Service{}, err
}
service.Init()
return service, nil