Fix Workhorse linter warnings (part 38)
Problem
make golangci
linter detects warnings in following Workhorse files
How to verify
make golangci | grep -E "cmd/gitlab-workhorse/(jobs_test.go|main.go|listener.go|main_test.go|proxy_test.go|raven.go)"
cmd/gitlab-workhorse/main.go:172:20: Error return value of `closer.Close` is not checked (errcheck)
cmd/gitlab-workhorse/main.go:240:26: Error return value of `accessCloser.Close` is not checked (errcheck)
cmd/gitlab-workhorse/raven.go:17:14: Error return value of `raven.SetDSN` is not checked (errcheck)
cmd/gitlab-workhorse/main.go:73: Function 'buildConfig' has too many statements (62 > 40) (funlen)
cmd/gitlab-workhorse/main.go:167: Function 'run' has too many statements (61 > 40) (funlen)
cmd/gitlab-workhorse/main_test.go:59:2: exitAfterDefer: os.Exit will exit, and `defer gitaly.CloseConnections()` will not run (gocritic)
cmd/gitlab-workhorse/main_test.go:518:3: ifElseChain: rewrite if-else to switch statement (gocritic)
cmd/gitlab-workhorse/main_test.go:155:66: wrapperFunc: use http.NotFoundHandler method in `http.HandlerFunc(http.NotFound)` (gocritic)
cmd/gitlab-workhorse/listener.go:34:16: G402: TLS MinVersion too low. (gosec)
cmd/gitlab-workhorse/main.go:9:2: G108: Profiling endpoint is automatically exposed on /debug/pprof (gosec)
cmd/gitlab-workhorse/main.go:197:30: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
cmd/gitlab-workhorse/main.go:264:10: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec)
cmd/gitlab-workhorse/proxy_test.go:76:6: var-naming: var tsUrl should be tsURL (revive)
cmd/gitlab-workhorse/main_test.go:650:4: var-naming: var propagatedRequestId should be propagatedRequestID (revive)
cmd/gitlab-workhorse/main_test.go:932:4: var-naming: var originResourceUrl should be originResourceURL (revive)
cmd/gitlab-workhorse/main_test.go:791:16: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
cmd/gitlab-workhorse/main_test.go:245:25: unnecessary conversion (unconvert)
cmd/gitlab-workhorse/jobs_test.go:37:29: response body must be closed (bodyclose)
cmd/gitlab-workhorse/jobs_test.go:42:29: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:106:24: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:142:24: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:162:23: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:185:24: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:211:25: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:242:23: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:415:38: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:430:38: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:484:40: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:508:23: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:574:21: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:657:22: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:866:25: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main_test.go:891:25: response body must be closed (bodyclose)
cmd/gitlab-workhorse/main.go:180:6: shadow: declaration of "err" shadows declaration at line 168 (govet)
cmd/gitlab-workhorse/main.go:192:6: shadow: declaration of "err" shadows declaration at line 168 (govet)
cmd/gitlab-workhorse/main.go:202:6: shadow: declaration of "err" shadows declaration at line 168 (govet)
cmd/gitlab-workhorse/main.go:211:6: shadow: declaration of "err" shadows declaration at line 168 (govet)
cmd/gitlab-workhorse/main.go:232:5: shadow: declaration of "err" shadows declaration at line 168 (govet)
cmd/gitlab-workhorse/proxy_test.go:54:9: shadow: declaration of "err" shadows declaration at line 35 (govet)
cmd/gitlab-workhorse/proxy_test.go:86:6: shadow: declaration of "err" shadows declaration at line 77 (govet)
cmd/gitlab-workhorse/main_test.go:456:3: bool-compare: use require.True (testifylint)
cmd/gitlab-workhorse/main_test.go:578:3: len: use require.Len (testifylint)
cmd/gitlab-workhorse/main_test.go:661:4: len: use require.Len (testifylint)
Solution
Resolve warnings
Edited by Vasilii Iakliushin