Skip to content

Commit d51b5e4

Browse files
authored
chore: update linter (#2046)
1 parent 4f242c9 commit d51b5e4

File tree

38 files changed

+127
-116
lines changed

38 files changed

+127
-116
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
env:
1515
GO_VERSION: stable
16-
GOLANGCI_LINT_VERSION: v1.54.1
16+
GOLANGCI_LINT_VERSION: v1.55.1
1717
HUGO_VERSION: '0.117.0'
1818
CGO_ENABLED: 0
1919
LEGO_E2E_TESTS: CI

.golangci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ linters-settings:
8888
disabled: true
8989
- name: unreachable-code
9090
- name: redefines-builtin-id
91+
testifylint:
92+
enable:
93+
- bool-compare
94+
- compares
95+
- empty
96+
- error-is-as
97+
- error-nil
98+
- expected-actual
99+
- float-compare
100+
- len
101+
- suite-dont-use-pkg
102+
- suite-extra-assert-call
103+
- suite-thelper
91104

92105
linters:
93106
enable-all: true

certificate/errors_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"testing"
66

7-
"github.com/stretchr/testify/assert"
87
"github.com/stretchr/testify/require"
98
)
109

@@ -28,7 +27,7 @@ func Test_obtainError_Join(t *testing.T) {
2827
err := failures.Join()
2928

3029
to := &TomatoError{}
31-
assert.ErrorAs(t, err, &to)
30+
require.ErrorAs(t, err, &to)
3231
}
3332

3433
func Test_obtainError_Join_multiple_domains(t *testing.T) {
@@ -40,16 +39,16 @@ func Test_obtainError_Join_multiple_domains(t *testing.T) {
4039
err := failures.Join()
4140

4241
to := &TomatoError{}
43-
assert.ErrorAs(t, err, &to)
42+
require.ErrorAs(t, err, &to)
4443

4544
ca := &CarrotError{}
46-
assert.ErrorAs(t, err, &ca)
45+
require.ErrorAs(t, err, &ca)
4746
}
4847

4948
func Test_obtainError_Join_no_error(t *testing.T) {
5049
failures := newObtainError()
5150

52-
assert.NoError(t, failures.Join())
51+
require.NoError(t, failures.Join())
5352
}
5453

5554
func Test_obtainError_Join_same_domain(t *testing.T) {
@@ -66,5 +65,5 @@ func Test_obtainError_Join_same_domain(t *testing.T) {
6665
}
6766

6867
ca := &CarrotError{}
69-
assert.ErrorAs(t, err, &ca)
68+
require.ErrorAs(t, err, &ca)
7069
}

challenge/dns01/dns_challenge_manual_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"os"
66
"testing"
77

8-
"github.com/stretchr/testify/assert"
98
"github.com/stretchr/testify/require"
109
)
1110

@@ -32,14 +31,14 @@ func TestDNSProviderManual(t *testing.T) {
3231
for _, test := range testCases {
3332
t.Run(test.desc, func(t *testing.T) {
3433
file, err := os.CreateTemp("", "lego_test")
35-
assert.NoError(t, err)
34+
require.NoError(t, err)
3635
defer func() { _ = os.Remove(file.Name()) }()
3736

3837
_, err = file.WriteString(test.input)
39-
assert.NoError(t, err)
38+
require.NoError(t, err)
4039

4140
_, err = file.Seek(0, io.SeekStart)
42-
assert.NoError(t, err)
41+
require.NoError(t, err)
4342

4443
os.Stdin = file
4544

challenge/tlsalpn01/tls_alpn_challenge_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func TestChallengeIPaddress(t *testing.T) {
141141
assert.Len(t, connState.PeerCertificates, 1, "Expected the challenge server to return exactly one certificate")
142142

143143
remoteCert := connState.PeerCertificates[0]
144-
assert.Len(t, remoteCert.DNSNames, 0, "Expected the challenge certificate to have no DNSNames entry in context of challenge for IP")
144+
assert.Empty(t, remoteCert.DNSNames, "Expected the challenge certificate to have no DNSNames entry in context of challenge for IP")
145145
assert.Len(t, remoteCert.IPAddresses, 1, "Expected the challenge certificate to have exactly one IPAddresses entry")
146146
assert.True(t, net.ParseIP("127.0.0.1").Equal(remoteCert.IPAddresses[0]), "challenge certificate IPAddress ")
147147
assert.NotEmpty(t, remoteCert.Extensions, "Expected the challenge certificate to contain extensions")

cmd/zz_gen_cmd_dnshelp.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,17 +1635,17 @@ func displayDNSHelp(w io.Writer, name string) error {
16351635
ew.writeln()
16361636

16371637
ew.writeln(`Credentials:`)
1638-
ew.writeln(` - "LIQUID_WEB_PASSWORD": Liquid Web API Password`)
1639-
ew.writeln(` - "LIQUID_WEB_USERNAME": Liquid Web API Username`)
1638+
ew.writeln(` - "LWAPI_PASSWORD": Liquid Web API Password`)
1639+
ew.writeln(` - "LWAPI_USERNAME": Liquid Web API Username`)
16401640
ew.writeln()
16411641

16421642
ew.writeln(`Additional Configuration:`)
1643-
ew.writeln(` - "LIQUID_WEB_HTTP_TIMEOUT": Maximum waiting time for the DNS records to be created (not verified)`)
1644-
ew.writeln(` - "LIQUID_WEB_POLLING_INTERVAL": Time between DNS propagation check`)
1645-
ew.writeln(` - "LIQUID_WEB_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`)
1646-
ew.writeln(` - "LIQUID_WEB_TTL": The TTL of the TXT record used for the DNS challenge`)
1647-
ew.writeln(` - "LIQUID_WEB_URL": Liquid Web API endpoint`)
1648-
ew.writeln(` - "LIQUID_WEB_ZONE": DNS Zone`)
1643+
ew.writeln(` - "LWAPI_HTTP_TIMEOUT": Maximum waiting time for the DNS records to be created (not verified)`)
1644+
ew.writeln(` - "LWAPI_POLLING_INTERVAL": Time between DNS propagation check`)
1645+
ew.writeln(` - "LWAPI_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`)
1646+
ew.writeln(` - "LWAPI_TTL": The TTL of the TXT record used for the DNS challenge`)
1647+
ew.writeln(` - "LWAPI_URL": Liquid Web API endpoint`)
1648+
ew.writeln(` - "LWAPI_ZONE": DNS Zone`)
16491649

16501650
ew.writeln()
16511651
ew.writeln(`More information: https://go-acme.github.io/lego/dns/liquidweb`)

docs/content/dns/zz_gen_liquidweb.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Configuration for [Liquid Web](https://liquidweb.com).
2626
Here is an example bash command using the Liquid Web provider:
2727

2828
```bash
29-
LIQUID_WEB_USERNAME=someuser \
30-
LIQUID_WEB_PASSWORD=somepass \
29+
LWAPI_USERNAME=someuser \
30+
LWAPI_PASSWORD=somepass \
3131
lego --email [email protected] --dns liquidweb --domains my.example.org run
3232
```
3333

@@ -38,8 +38,8 @@ lego --email [email protected] --dns liquidweb --domains my.example.org run
3838

3939
| Environment Variable Name | Description |
4040
|-----------------------|-------------|
41-
| `LIQUID_WEB_PASSWORD` | Liquid Web API Password |
42-
| `LIQUID_WEB_USERNAME` | Liquid Web API Username |
41+
| `LWAPI_PASSWORD` | Liquid Web API Password |
42+
| `LWAPI_USERNAME` | Liquid Web API Username |
4343

4444
The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
4545
More information [here]({{< ref "dns#configuration-and-credentials" >}}).
@@ -49,12 +49,12 @@ More information [here]({{< ref "dns#configuration-and-credentials" >}}).
4949

5050
| Environment Variable Name | Description |
5151
|--------------------------------|-------------|
52-
| `LIQUID_WEB_HTTP_TIMEOUT` | Maximum waiting time for the DNS records to be created (not verified) |
53-
| `LIQUID_WEB_POLLING_INTERVAL` | Time between DNS propagation check |
54-
| `LIQUID_WEB_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation |
55-
| `LIQUID_WEB_TTL` | The TTL of the TXT record used for the DNS challenge |
56-
| `LIQUID_WEB_URL` | Liquid Web API endpoint |
57-
| `LIQUID_WEB_ZONE` | DNS Zone |
52+
| `LWAPI_HTTP_TIMEOUT` | Maximum waiting time for the DNS records to be created (not verified) |
53+
| `LWAPI_POLLING_INTERVAL` | Time between DNS propagation check |
54+
| `LWAPI_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation |
55+
| `LWAPI_TTL` | The TTL of the TXT record used for the DNS challenge |
56+
| `LWAPI_URL` | Liquid Web API endpoint |
57+
| `LWAPI_ZONE` | DNS Zone |
5858

5959
The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.
6060
More information [here]({{< ref "dns#configuration-and-credentials" >}}).

providers/dns/acmedns/acmedns.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ const (
2828
type acmeDNSClient interface {
2929
// UpdateTXTRecord updates the provided account's TXT record
3030
// to the given value or returns an error.
31-
UpdateTXTRecord(goacmedns.Account, string) error
31+
UpdateTXTRecord(account goacmedns.Account, value string) error
3232
// RegisterAccount registers and returns a new account
3333
// with the given allowFrom restriction or returns an error.
34-
RegisterAccount([]string) (goacmedns.Account, error)
34+
RegisterAccount(allowFrom []string) (goacmedns.Account, error)
3535
}
3636

3737
// DNSProvider implements the challenge.Provider interface.

providers/dns/autodns/autodns_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"testing"
55

66
"github.com/go-acme/lego/v4/platform/tester"
7-
"github.com/stretchr/testify/assert"
87
"github.com/stretchr/testify/require"
98
)
109

@@ -133,10 +132,10 @@ func TestLivePresent(t *testing.T) {
133132

134133
envTest.RestoreEnv()
135134
provider, err := NewDNSProvider()
136-
assert.NoError(t, err)
135+
require.NoError(t, err)
137136

138137
err = provider.Present(envTest.GetDomain(), "", "123d==")
139-
assert.NoError(t, err)
138+
require.NoError(t, err)
140139
}
141140

142141
func TestLiveCleanUp(t *testing.T) {
@@ -146,8 +145,8 @@ func TestLiveCleanUp(t *testing.T) {
146145

147146
envTest.RestoreEnv()
148147
provider, err := NewDNSProvider()
149-
assert.NoError(t, err)
148+
require.NoError(t, err)
150149

151150
err = provider.CleanUp(envTest.GetDomain(), "", "123d==")
152-
assert.NoError(t, err)
151+
require.NoError(t, err)
153152
}

providers/dns/brandit/internal/client.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"io"
1212
"net/http"
1313
"net/url"
14+
"strconv"
1415
"strings"
1516
"time"
1617

@@ -58,7 +59,7 @@ func (c *Client) ListRecords(ctx context.Context, account, dnsZone string) (*Lis
5859
}
5960

6061
for len(result.Response.RR) < result.Response.Total[0] {
61-
query.Add("first", fmt.Sprint(result.Response.Last[0]+1))
62+
query.Add("first", strconv.Itoa(result.Response.Last[0]+1))
6263

6364
tmp := &Response[*ListRecordsResponse]{}
6465
err := c.do(ctx, query, tmp)
@@ -76,7 +77,7 @@ func (c *Client) ListRecords(ctx context.Context, account, dnsZone string) (*Lis
7677
// AddRecord adds a DNS record.
7778
// https://portal.brandit.com/apidocv3#addDNSRR
7879
func (c *Client) AddRecord(ctx context.Context, domainName, account, newRecordID string, record Record) (*AddRecord, error) {
79-
value := strings.Join([]string{record.Name, fmt.Sprint(record.TTL), "IN", record.Type, record.Content}, " ")
80+
value := strings.Join([]string{record.Name, strconv.Itoa(record.TTL), "IN", record.Type, record.Content}, " ")
8081

8182
query := url.Values{}
8283
query.Add("command", "addDNSRR")

0 commit comments

Comments
 (0)