Skip to content

Commit

Permalink
chore: update linter (go-acme#1708)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Sep 2, 2022
1 parent be0c6c7 commit d99c75a
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
env:
GO_VERSION: 1.19
GOLANGCI_LINT_VERSION: v1.48.0
GOLANGCI_LINT_VERSION: v1.49.0
HUGO_VERSION: 0.54.0
CGO_ENABLED: 0
LEGO_E2E_TESTS: CI
Expand Down
25 changes: 10 additions & 15 deletions .golangci.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[run]
deadline = "5m"
timeout = "5m"
skip-files = []

[linters-settings]
Expand Down Expand Up @@ -53,13 +53,16 @@
[linters]
enable-all = true
disable = [
"deadcode", # deprecated
"exhaustivestruct", # deprecated
"golint", # deprecated
"ifshort", # deprecated
"interfacer", # deprecated
"maligned", # deprecated
"scopelint", # deprecated
"golint", # deprecated
"nosnakecase", # deprecated
"ifshort", # deprecated
"exhaustivestruct", # deprecated
"scopelint", # deprecated
"structcheck", # deprecated
"varcheck", # deprecated
"cyclop", # duplicate of gocyclo
"sqlclosecheck", # not relevant (SQL)
"rowserrcheck", # not relevant (SQL)
Expand Down Expand Up @@ -102,7 +105,8 @@
exclude = [
"Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked",
"exported (type|method|function) (.+) should have comment or be unexported",
"ST1000: at least one file in a package should have a package comment"
"ST1000: at least one file in a package should have a package comment",
"package-comments: should have a package comment",
]
[[issues.exclude-rules]]
path = "(.+)_test.go"
Expand Down Expand Up @@ -197,12 +201,3 @@
[[issues.exclude-rules]]
path = "providers/dns/sakuracloud/client.go"
text = "mu is a global variable"
[[issues.exclude-rules]]
path = "providers/dns/tencentcloud/client.go"
text = "RESOURCENOTFOUND_NODATAOFRECORD contains underscore."
[[issues.exclude-rules]]
path = "providers/dns/ibmcloud/internal/wrapper.go"
text = "Dns_Domain(_ResourceRecord)? contains underscore."
[[issues.exclude-rules]]
path = "providers/dns/rfc2136/"
text = "RR_Header contains underscore."
2 changes: 1 addition & 1 deletion providers/dns/clouddns/internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (c *Client) doRequest(req *http.Request) ([]byte, error) {
}
defer resp.Body.Close()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return nil, readError(req, resp)
}

Expand Down
2 changes: 1 addition & 1 deletion providers/dns/cloudns/internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (c *Client) doRequest(method string, uri *url.URL) (json.RawMessage, error)
return nil, errors.New(toUnreadableBodyMessage(req, content))
}

if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("invalid code (%d), error: %s", resp.StatusCode, content)
}

Expand Down
4 changes: 2 additions & 2 deletions providers/dns/digitalocean/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (d *DNSProvider) removeTxtRecord(domain string, recordID int) error {
}
defer resp.Body.Close()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return readError(req, resp)
}

Expand Down Expand Up @@ -80,7 +80,7 @@ func (d *DNSProvider) addTxtRecord(fqdn, value string) (*txtRecordResponse, erro
}
defer resp.Body.Close()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return nil, readError(req, resp)
}

Expand Down
3 changes: 2 additions & 1 deletion providers/dns/dreamhost/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"

"github.com/go-acme/lego/v4/log"
Expand Down Expand Up @@ -49,7 +50,7 @@ func (d *DNSProvider) updateTxtRecord(u fmt.Stringer) error {
}
defer resp.Body.Close()

if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode)
}

Expand Down
6 changes: 3 additions & 3 deletions providers/dns/dyn/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{})
}
defer resp.Body.Close()

if resp.StatusCode >= 500 {
if resp.StatusCode >= http.StatusInternalServerError {
return nil, fmt.Errorf("API request failed with HTTP status code %d", resp.StatusCode)
}

Expand All @@ -131,9 +131,9 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{})
return nil, err
}

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return nil, fmt.Errorf("API request failed with HTTP status code %d: %s", resp.StatusCode, dynRes.Messages)
} else if resp.StatusCode == 307 {
} else if resp.StatusCode == http.StatusTemporaryRedirect {
// TODO add support for HTTP 307 response and long running jobs
return nil, errors.New("API request returned HTTP 307. This is currently unsupported")
}
Expand Down
4 changes: 2 additions & 2 deletions providers/dns/gandiv5/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ func (d *DNSProvider) do(req *http.Request, v interface{}) error {
}

func checkResponse(resp *http.Response) error {
if resp.StatusCode == 404 && resp.Request.Method == http.MethodGet {
if resp.StatusCode == http.StatusNotFound && resp.Request.Method == http.MethodGet {
return nil
}

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
data, err := readBody(resp)
if err != nil {
return fmt.Errorf("%d [%s] request failed: %w", resp.StatusCode, http.StatusText(resp.StatusCode), err)
Expand Down
2 changes: 1 addition & 1 deletion providers/dns/glesys/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{})
}
defer resp.Body.Close()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return nil, fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode)
}

Expand Down
2 changes: 1 addition & 1 deletion providers/dns/joker/internal/dmapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (c *Client) postRequest(cmd string, data url.Values) (*Response, error) {
return nil, err
}

if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("HTTP error %d [%s]: %v", resp.StatusCode, http.StatusText(resp.StatusCode), string(body))
}

Expand Down
2 changes: 1 addition & 1 deletion providers/dns/mydnsjp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (d *DNSProvider) doRequest(domain, value, cmd string) error {

defer resp.Body.Close()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
var content []byte
content, err = io.ReadAll(resp.Body)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions providers/dns/mythicbeasts/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (d *DNSProvider) createTXTRecord(zone, leaf, value string) error {
return fmt.Errorf("createTXTRecord: %w", err)
}

if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("createTXTRecord: error in API: %d", resp.StatusCode)
}

Expand Down Expand Up @@ -221,7 +221,7 @@ func (d *DNSProvider) removeTXTRecord(zone, leaf, value string) error {
return fmt.Errorf("removeTXTRecord: %w", err)
}

if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("removeTXTRecord: error in API: %d", resp.StatusCode)
}

Expand Down
2 changes: 1 addition & 1 deletion providers/dns/namecheap/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (d *DNSProvider) do(req *http.Request, out interface{}) error {
return err
}

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
var body []byte
body, err = readBody(resp)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions providers/dns/otc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (d *DNSProvider) loginRequest() error {
}
defer resp.Body.Close()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return fmt.Errorf("OTC API request failed with HTTP status code %d", resp.StatusCode)
}

Expand Down Expand Up @@ -253,7 +253,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{})
}
defer resp.Body.Close()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return nil, fmt.Errorf("OTC API request %s failed with HTTP status code %d", url, resp.StatusCode)
}

Expand Down
2 changes: 1 addition & 1 deletion providers/dns/safedns/internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (c *Client) RemoveRecord(zone string, recordID int) error {
}
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return readError(req, resp)
}

Expand Down
4 changes: 2 additions & 2 deletions providers/dns/vercel/internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *Client) CreateRecord(zone string, record Record) (*CreateRecordResponse
}
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return nil, readError(req, resp)
}

Expand Down Expand Up @@ -98,7 +98,7 @@ func (c *Client) DeleteRecord(zone string, recordID string) error {
}
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode >= 400 {
if resp.StatusCode >= http.StatusBadRequest {
return readError(req, resp)
}

Expand Down

0 comments on commit d99c75a

Please sign in to comment.