chore: update golangci-lint. (#782)

This commit is contained in:
Ludovic Fernandez 2019-02-06 18:15:53 +01:00 committed by GitHub
parent f05aa4c241
commit 6fdf45c474
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 44 additions and 43 deletions

View file

@ -41,6 +41,7 @@
"cyclomatic complexity (.+) of func `NewDNSChallengeProviderByName` is high (.+)", # providers/dns/dns_providers.go
"string `(lego\\.wtf|manhattan)` has (\\d+) occurrences, make it a constant", #providers/dns/gcloud/googlecloud_test.go
"(dnsHelp|createRenew\\$1|createRun\\$1|run) - result 0 \\(error\\) is always nil", # cmd/
"`(tlsFeatureExtensionOID|ocspMustStapleFeature)` is a global variable", # certcrypto/crypto.go
"`(defaultNameservers|recursiveNameservers|dnsTimeout|fqdnToZone|muFqdnToZone)` is a global variable", # challenge/dns01/nameserver.go
"`idPeAcmeIdentifierV1` is a global variable", # challenge/tlsalpn01/tls_alpn_challenge.go

View file

@ -30,7 +30,7 @@ before_install:
- go get -u github.com/letsencrypt/pebble/...
# Install linters and misspell
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.12.5
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.13.2
- golangci-lint --version
install:

View file

@ -77,7 +77,7 @@ func TestCertificateService_Get_issuerRelUp(t *testing.T) {
mux, apiURL, tearDown := tester.SetupFakeAPI()
defer tearDown()
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Link", "<"+apiURL+`/issuer>; rel="up"`)
_, err := w.Write([]byte(certResponseMock))
if err != nil {
@ -85,7 +85,7 @@ func TestCertificateService_Get_issuerRelUp(t *testing.T) {
}
})
mux.HandleFunc("/issuer", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/issuer", func(w http.ResponseWriter, _ *http.Request) {
p, _ := pem.Decode([]byte(issuerMock))
_, err := w.Write(p.Bytes)
if err != nil {
@ -109,7 +109,7 @@ func TestCertificateService_Get_embeddedIssuer(t *testing.T) {
mux, apiURL, tearDown := tester.SetupFakeAPI()
defer tearDown()
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
_, err := w.Write([]byte(certResponseMock))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)

View file

@ -12,7 +12,7 @@ import (
)
func TestNotHoldingLockWhileMakingHTTPRequests(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
time.Sleep(250 * time.Millisecond)
w.Header().Add("Replay-Nonce", "12345")
w.Header().Add("Retry-After", "0")

View file

@ -13,7 +13,7 @@ import (
)
func TestNotHoldingLockWhileMakingHTTPRequests(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
time.Sleep(250 * time.Millisecond)
w.Header().Add("Replay-Nonce", "12345")
w.Header().Add("Retry-After", "0")

View file

@ -12,7 +12,7 @@ import (
func TestDo_UserAgentOnAllHTTPMethod(t *testing.T) {
var ua, method string
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
ua = r.Header.Get("User-Agent")
method = r.Method
}))

View file

@ -80,7 +80,7 @@ func Test_checkResponse(t *testing.T) {
mux, apiURL, tearDown := tester.SetupFakeAPI()
defer tearDown()
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
_, err := w.Write([]byte(certResponseMock))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
@ -119,7 +119,7 @@ func Test_checkResponse_issuerRelUp(t *testing.T) {
mux, apiURL, tearDown := tester.SetupFakeAPI()
defer tearDown()
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Link", "<"+apiURL+`/issuer>; rel="up"`)
_, err := w.Write([]byte(certResponseMock))
if err != nil {
@ -127,7 +127,7 @@ func Test_checkResponse_issuerRelUp(t *testing.T) {
}
})
mux.HandleFunc("/issuer", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/issuer", func(w http.ResponseWriter, _ *http.Request) {
p, _ := pem.Decode([]byte(issuerMock))
_, err := w.Write(p.Bytes)
if err != nil {
@ -167,7 +167,7 @@ func Test_checkResponse_embeddedIssuer(t *testing.T) {
mux, apiURL, tearDown := tester.SetupFakeAPI()
defer tearDown()
mux.HandleFunc("/certificate", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/certificate", func(w http.ResponseWriter, _ *http.Request) {
_, err := w.Write([]byte(certResponseMock))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)

View file

@ -111,7 +111,7 @@ func TestNewDNSProviderConfig(t *testing.T) {
tenantID: "C",
subscriptionID: "",
resourceGroup: "",
handler: func(w http.ResponseWriter, r *http.Request) {
handler: func(w http.ResponseWriter, _ *http.Request) {
_, err := w.Write([]byte("foo"))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)

View file

@ -184,13 +184,13 @@ func TestClient_Login_errors(t *testing.T) {
}{
{
desc: "HTTP error",
handler: func(rw http.ResponseWriter, req *http.Request) {
handler: func(rw http.ResponseWriter, _ *http.Request) {
http.Error(rw, "error message", http.StatusInternalServerError)
},
},
{
desc: "API error",
handler: func(rw http.ResponseWriter, req *http.Request) {
handler: func(rw http.ResponseWriter, _ *http.Request) {
response := `
{
"serverrequestid":"YxTr4EzdbJ101T211zR4yzUEMVE",
@ -210,7 +210,7 @@ func TestClient_Login_errors(t *testing.T) {
},
{
desc: "responsedata marshaling error",
handler: func(rw http.ResponseWriter, req *http.Request) {
handler: func(rw http.ResponseWriter, _ *http.Request) {
response := `
{
"serverrequestid": "srv-request-id",
@ -289,13 +289,13 @@ func TestClient_Logout_errors(t *testing.T) {
}{
{
desc: "HTTP error",
handler: func(rw http.ResponseWriter, req *http.Request) {
handler: func(rw http.ResponseWriter, _ *http.Request) {
http.Error(rw, "error message", http.StatusInternalServerError)
},
},
{
desc: "API error",
handler: func(rw http.ResponseWriter, req *http.Request) {
handler: func(rw http.ResponseWriter, _ *http.Request) {
response := `
{
"serverrequestid":"YxTr4EzdbJ101T211zR4yzUEMVE",
@ -417,13 +417,13 @@ func TestClient_GetDNSRecords_errors(t *testing.T) {
}{
{
desc: "HTTP error",
handler: func(rw http.ResponseWriter, req *http.Request) {
handler: func(rw http.ResponseWriter, _ *http.Request) {
http.Error(rw, "error message", http.StatusInternalServerError)
},
},
{
desc: "API error",
handler: func(rw http.ResponseWriter, req *http.Request) {
handler: func(rw http.ResponseWriter, _ *http.Request) {
response := `
{
"serverrequestid":"YxTr4EzdbJ101T211zR4yzUEMVE",

View file

@ -11,7 +11,7 @@ import (
)
func runTestServer(responseBody string, statusCode int) *httptest.Server {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(statusCode)
fmt.Fprintln(w, responseBody)
}))

View file

@ -41,7 +41,7 @@ func (m *DNSServerMock) ShutdownServer() {
// HandleAuthSuccessfully Handle auth successfully
func (m *DNSServerMock) HandleAuthSuccessfully() {
m.Mux.HandleFunc("/v3/auth/token", func(w http.ResponseWriter, r *http.Request) {
m.Mux.HandleFunc("/v3/auth/token", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("X-Subject-Token", fakeOTCToken)
fmt.Fprintf(w, `{

View file

@ -135,7 +135,7 @@ func identityHandler(dnsEndpoint string) http.Handler {
resp := strings.Replace(identityResponseMock, "https://dns.api.rackspacecloud.com/v1.0/123456", dnsEndpoint, 1)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, resp)
fmt.Fprint(w, resp)
})
}
@ -146,7 +146,7 @@ func dnsHandler() *http.ServeMux {
mux.HandleFunc("/123456/domains", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("name") == "example.com" {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, zoneDetailsMock)
fmt.Fprint(w, zoneDetailsMock)
return
}
w.WriteHeader(http.StatusBadRequest)
@ -168,12 +168,12 @@ func dnsHandler() *http.ServeMux {
}
w.WriteHeader(http.StatusAccepted)
fmt.Fprintf(w, recordResponseMock)
fmt.Fprint(w, recordResponseMock)
// Used by `findTxtRecord()` finding `record.ID` "?type=TXT&name=_acme-challenge.example.com"
case http.MethodGet:
if r.URL.Query().Get("type") == "TXT" && r.URL.Query().Get("name") == "_acme-challenge.example.com" {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, recordDetailsMock)
fmt.Fprint(w, recordDetailsMock)
return
}
w.WriteHeader(http.StatusBadRequest)
@ -182,7 +182,7 @@ func dnsHandler() *http.ServeMux {
case http.MethodDelete:
if r.URL.Query().Get("id") == "TXT-654321" {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, recordDeleteMock)
fmt.Fprint(w, recordDeleteMock)
return
}
w.WriteHeader(http.StatusBadRequest)

View file

@ -157,7 +157,7 @@ func TestDNSProvider_getZoneRecords(t *testing.T) {
provider, mux, tearDown := setupMockAPITest()
defer tearDown()
mux.HandleFunc("/STACK_ID/zones/A/records", func(w http.ResponseWriter, req *http.Request) {
mux.HandleFunc("/STACK_ID/zones/A/records", func(w http.ResponseWriter, _ *http.Request) {
content := `
{
"records": [
@ -188,7 +188,7 @@ func TestDNSProvider_getZoneRecords_apiError(t *testing.T) {
provider, mux, tearDown := setupMockAPITest()
defer tearDown()
mux.HandleFunc("/STACK_ID/zones/A/records", func(w http.ResponseWriter, req *http.Request) {
mux.HandleFunc("/STACK_ID/zones/A/records", func(w http.ResponseWriter, _ *http.Request) {
content := `
{
"code": 401,
@ -213,7 +213,7 @@ func TestDNSProvider_getZones(t *testing.T) {
provider, mux, tearDown := setupMockAPITest()
defer tearDown()
mux.HandleFunc("/STACK_ID/zones", func(w http.ResponseWriter, req *http.Request) {
mux.HandleFunc("/STACK_ID/zones", func(w http.ResponseWriter, _ *http.Request) {
content := `
{
"pageInfo": {

View file

@ -145,7 +145,7 @@ func muxSuccess() *http.ServeMux {
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, tokenResponseMock)
fmt.Fprint(w, tokenResponseMock)
return
}
w.WriteHeader(http.StatusBadRequest)
@ -154,7 +154,7 @@ func muxSuccess() *http.ServeMux {
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("search") == "example.com" {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, domainsResponseMock)
fmt.Fprint(w, domainsResponseMock)
return
}
w.WriteHeader(http.StatusNotFound)
@ -165,14 +165,14 @@ func muxSuccess() *http.ServeMux {
case http.MethodGet:
if r.URL.Query().Get("domain_id") == "1" {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, recordsResponseMock)
fmt.Fprint(w, recordsResponseMock)
return
}
w.WriteHeader(http.StatusNotFound)
return
case http.MethodPost:
w.WriteHeader(http.StatusCreated)
fmt.Fprintf(w, recordCreatedResponseMock)
fmt.Fprint(w, recordCreatedResponseMock)
return
}
w.WriteHeader(http.StatusBadRequest)
@ -181,7 +181,7 @@ func muxSuccess() *http.ServeMux {
mux.HandleFunc("/1.0/records/3", func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodDelete {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, recordDeletedResponseMock)
fmt.Fprint(w, recordDeletedResponseMock)
return
}
w.WriteHeader(http.StatusBadRequest)
@ -201,13 +201,13 @@ func muxFailToFindZone() *http.ServeMux {
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, tokenResponseMock)
fmt.Fprint(w, tokenResponseMock)
return
}
w.WriteHeader(http.StatusBadRequest)
})
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusNotFound)
})
@ -220,7 +220,7 @@ func muxFailToCreateTXT() *http.ServeMux {
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, tokenResponseMock)
fmt.Fprint(w, tokenResponseMock)
return
}
w.WriteHeader(http.StatusBadRequest)
@ -229,7 +229,7 @@ func muxFailToCreateTXT() *http.ServeMux {
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("search") == testDomain {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, domainsResponseMock)
fmt.Fprint(w, domainsResponseMock)
return
}
w.WriteHeader(http.StatusNotFound)
@ -240,7 +240,7 @@ func muxFailToCreateTXT() *http.ServeMux {
case http.MethodGet:
if r.URL.Query().Get("domain_id") == "1" {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, recordsResponseMock)
fmt.Fprint(w, recordsResponseMock)
return
}
w.WriteHeader(http.StatusNotFound)
@ -261,7 +261,7 @@ func muxFailToGetRecordID() *http.ServeMux {
mux.HandleFunc("/1.0/token", func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, tokenResponseMock)
fmt.Fprint(w, tokenResponseMock)
return
}
w.WriteHeader(http.StatusBadRequest)
@ -270,7 +270,7 @@ func muxFailToGetRecordID() *http.ServeMux {
mux.HandleFunc("/1.0/domains", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("search") == testDomain {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, domainsResponseMock)
fmt.Fprint(w, domainsResponseMock)
return
}
w.WriteHeader(http.StatusNotFound)

View file

@ -17,7 +17,7 @@ func TestRegistrar_ResolveAccountByKey(t *testing.T) {
mux, apiURL, tearDown := tester.SetupFakeAPI()
defer tearDown()
mux.HandleFunc("/account", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/account", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Location", apiURL+"/account_recovery")
_, err := w.Write([]byte("{}"))
if err != nil {
@ -25,7 +25,7 @@ func TestRegistrar_ResolveAccountByKey(t *testing.T) {
}
})
mux.HandleFunc("/account_recovery", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/account_recovery", func(w http.ResponseWriter, _ *http.Request) {
err := tester.WriteJSONResponse(w, acme.Account{
Status: "valid",
})