Skip to content

Commit

Permalink
chore(lint): add new linters fatcontext, intrange and mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Oct 20, 2024
1 parent 8b5da2c commit 691ed32
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ linters:
- errname
- errorlint
- exhaustive
- fatcontext
- forcetypeassert
- gci
- gocheckcompilerdirectives
Expand All @@ -59,10 +60,12 @@ linters:
- importas
- inamedparam
- interfacebloat
- intrange
- ireturn
- lll
- maintidx
- makezero
- mirror
- misspell
- mnd
- musttag
Expand Down
2 changes: 1 addition & 1 deletion internal/update/getip.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func tryAndRepeatGettingIP(ctx context.Context, getIPFunc getIPFunc,
const tries = 3
logMessagePrefix := "obtaining " + version.String() + " address"
errs := make([]error, 0, tries)
for try := 0; try < tries; try++ {
for try := range tries {
ip, err = getIPFunc(ctx)
if err != nil {
errs = append(errs, err)
Expand Down
2 changes: 1 addition & 1 deletion internal/update/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewService(db Database, updater UpdaterInterface, ipGetter PublicIPFetcher,
func (s *Service) lookupIPsResilient(ctx context.Context, hostname string, tries int) (
ipv4 netip.Addr, ipv6 netip.Addr, err error,
) {
for i := 0; i < tries; i++ {
for range tries {
ipv4, ipv6, err = s.lookupIPs(ctx, hostname)
if err == nil {
return ipv4, ipv6, nil
Expand Down
3 changes: 1 addition & 2 deletions pkg/publicip/info/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ type provider interface {
get(ctx context.Context, ip netip.Addr) (result Result, err error)
}

//nolint:ireturn
func newProvider(providerName Provider, client *http.Client) provider {
func newProvider(providerName Provider, client *http.Client) provider { //nolint:ireturn
switch providerName {
case Ipinfo:
return newIpinfo(client)
Expand Down
3 changes: 2 additions & 1 deletion pkg/publicip/subfetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"sync/atomic"
)

func (f *Fetcher) getSubFetcher() ipFetcher { //nolint:ireturn
//nolint:ireturn
func (f *Fetcher) getSubFetcher() ipFetcher {
fetcher := f.fetchers[0]
if len(f.fetchers) > 1 { // cycling effect
index := int(atomic.AddUint32(f.counter, 1)) % len(f.fetchers)
Expand Down

0 comments on commit 691ed32

Please sign in to comment.