diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-05-25 04:55:06 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-06-01 03:39:03 +0300 |
commit | 01734cae272c4f898b233429aeba19892fa4857e (patch) | |
tree | e6153be8743403fbb5a35a77508363cf32d76a06 | |
parent | 9daf8dcc19c486c787d0fb4ebfa19e21ac492cd1 (diff) |
Enable deadcode linter
-rw-r--r-- | .golangci.yml | 4 | ||||
-rw-r--r-- | app.go | 12 | ||||
-rw-r--r-- | internal/auth/auth.go | 1 | ||||
-rw-r--r-- | internal/domain/domain_test.go | 31 |
4 files changed, 4 insertions, 44 deletions
diff --git a/.golangci.yml b/.golangci.yml index 2df44324..583466b8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,8 +31,8 @@ linters: enable: # TODO: enable these linters on a separate MR https://gitlab.com/gitlab-org/gitlab-pages/-/issues/385#linters # - bodyclose -# - deadcode -# - dogsled + - deadcode + - dogsled - goconst - gocyclo - goimports @@ -2,7 +2,6 @@ package main import ( "crypto/tls" - "errors" "fmt" "net" "net/http" @@ -15,7 +14,7 @@ import ( "gitlab.com/gitlab-org/labkit/errortracking" labmetrics "gitlab.com/gitlab-org/labkit/metrics" "gitlab.com/gitlab-org/labkit/monitoring" - mimedb "gitlab.com/lupine/go-mimedb" + "gitlab.com/lupine/go-mimedb" "gitlab.com/gitlab-org/gitlab-pages/internal/acme" "gitlab.com/gitlab-org/gitlab-pages/internal/artifact" @@ -32,20 +31,13 @@ import ( ) const ( - xForwardedProto = "X-Forwarded-Proto" - xForwardedHost = "X-Forwarded-Host" - xForwardedProtoHTTPS = "https" + xForwardedHost = "X-Forwarded-Host" ) var ( corsHandler = cors.New(cors.Options{AllowedMethods: []string{"GET"}}) ) -var ( - errStartListener = errors.New("Could not start listener") - errX509KeyPair = errors.New("Could not initialize KeyPair") -) - type theApp struct { appConfig domains *source.Domains diff --git a/internal/auth/auth.go b/internal/auth/auth.go index a89dd599..b1198328 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -47,7 +47,6 @@ var ( errFailAuth = errors.New("Failed to authenticate request") errAuthNotConfigured = errors.New("Authentication is not configured") errQueryParameter = errors.New("Failed to parse domain query parameter") - errAuthInvalidToken = errors.New("Invalid token supplied") ) // Auth handles authenticating users with GitLab API diff --git a/internal/domain/domain_test.go b/internal/domain/domain_test.go index e22ff7a6..49d46cb3 100644 --- a/internal/domain/domain_test.go +++ b/internal/domain/domain_test.go @@ -1,11 +1,7 @@ package domain import ( - "compress/gzip" - "io/ioutil" "net/http" - "net/http/httptest" - "net/url" "os" "testing" @@ -88,33 +84,6 @@ func TestIsHTTPSOnly(t *testing.T) { } } -func testHTTPGzip(t *testing.T, handler http.HandlerFunc, mode, url string, values url.Values, acceptEncoding string, str interface{}, contentType string, ungzip bool) { - w := httptest.NewRecorder() - req, err := http.NewRequest(mode, url+"?"+values.Encode(), nil) - require.NoError(t, err) - if acceptEncoding != "" { - req.Header.Add("Accept-Encoding", acceptEncoding) - } - handler(w, req) - - if ungzip { - reader, err := gzip.NewReader(w.Body) - require.NoError(t, err) - defer reader.Close() - - contentEncoding := w.Header().Get("Content-Encoding") - require.Equal(t, "gzip", contentEncoding, "Content-Encoding") - - bytes, err := ioutil.ReadAll(reader) - require.NoError(t, err) - require.Contains(t, string(bytes), str) - } else { - require.Contains(t, w.Body.String(), str) - } - - require.Equal(t, contentType, w.Header().Get("Content-Type")) -} - func TestPredefined404ServeHTTP(t *testing.T) { cleanup := setUpTests(t) defer cleanup() |