Skip to content

Commit 691ed32

Browse files
committed
chore(lint): add new linters fatcontext, intrange and mirror
1 parent 8b5da2c commit 691ed32

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

.golangci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ linters:
3737
- errname
3838
- errorlint
3939
- exhaustive
40+
- fatcontext
4041
- forcetypeassert
4142
- gci
4243
- gocheckcompilerdirectives
@@ -59,10 +60,12 @@ linters:
5960
- importas
6061
- inamedparam
6162
- interfacebloat
63+
- intrange
6264
- ireturn
6365
- lll
6466
- maintidx
6567
- makezero
68+
- mirror
6669
- misspell
6770
- mnd
6871
- musttag

internal/update/getip.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func tryAndRepeatGettingIP(ctx context.Context, getIPFunc getIPFunc,
2121
const tries = 3
2222
logMessagePrefix := "obtaining " + version.String() + " address"
2323
errs := make([]error, 0, tries)
24-
for try := 0; try < tries; try++ {
24+
for try := range tries {
2525
ip, err = getIPFunc(ctx)
2626
if err != nil {
2727
errs = append(errs, err)

internal/update/service.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func NewService(db Database, updater UpdaterInterface, ipGetter PublicIPFetcher,
5454
func (s *Service) lookupIPsResilient(ctx context.Context, hostname string, tries int) (
5555
ipv4 netip.Addr, ipv6 netip.Addr, err error,
5656
) {
57-
for i := 0; i < tries; i++ {
57+
for range tries {
5858
ipv4, ipv6, err = s.lookupIPs(ctx, hostname)
5959
if err == nil {
6060
return ipv4, ipv6, nil

pkg/publicip/info/provider.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ type provider interface {
3737
get(ctx context.Context, ip netip.Addr) (result Result, err error)
3838
}
3939

40-
//nolint:ireturn
41-
func newProvider(providerName Provider, client *http.Client) provider {
40+
func newProvider(providerName Provider, client *http.Client) provider { //nolint:ireturn
4241
switch providerName {
4342
case Ipinfo:
4443
return newIpinfo(client)

pkg/publicip/subfetcher.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import (
44
"sync/atomic"
55
)
66

7-
func (f *Fetcher) getSubFetcher() ipFetcher { //nolint:ireturn
7+
//nolint:ireturn
8+
func (f *Fetcher) getSubFetcher() ipFetcher {
89
fetcher := f.fetchers[0]
910
if len(f.fetchers) > 1 { // cycling effect
1011
index := int(atomic.AddUint32(f.counter, 1)) % len(f.fetchers)

0 commit comments

Comments
 (0)