Skip to content

Commit

Permalink
fix(monitor): correct printf format string (#265)
Browse files Browse the repository at this point in the history
ci: really enable custom printf functions for govet
  • Loading branch information
favonia authored Nov 13, 2022
1 parent c54237d commit 0740d61
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
13 changes: 8 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ linters-settings:
settings:
printf:
funcs:
- (github.com/favonia/cloudflare-ddns/internal/pp).Infof
- (github.com/favonia/cloudflare-ddns/internal/pp).Noticef
- (github.com/favonia/cloudflare-ddns/internal/pp).Warningf
- (github.com/favonia/cloudflare-ddns/internal/pp).Errorf
- (github.com/favonia/cloudflare-ddns/internal/pp).printf
- (github.com/favonia/cloudflare-ddns/internal/pp.PP).Infof
- (github.com/favonia/cloudflare-ddns/internal/pp.PP).Noticef
- (github.com/favonia/cloudflare-ddns/internal/pp.PP).Warningf
- (github.com/favonia/cloudflare-ddns/internal/pp.PP).Errorf
- (*github.com/favonia/cloudflare-ddns/internal/mocks.MockPPMockRecorder).Infof
- (*github.com/favonia/cloudflare-ddns/internal/mocks.MockPPMockRecorder).Noticef
- (*github.com/favonia/cloudflare-ddns/internal/mocks.MockPPMockRecorder).Warningf
- (*github.com/favonia/cloudflare-ddns/internal/mocks.MockPPMockRecorder).Errorf

issues:
exclude-rules:
Expand Down
2 changes: 1 addition & 1 deletion internal/api/cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (h *CloudflareHandle) ActiveZones(ctx context.Context, ppfmt pp.PP, name st
"moved", // domain registrar not pointing to Cloudflare
"pending": // the setup was not completed
ppfmt.Warningf(pp.EmojiWarning, "Zone %q is %q; your Cloudflare setup is incomplete", name, zone.Status)
ppfmt.Warningf(pp.EmojiWarning, "Some features might stop working", name, zone.Status)
ppfmt.Warningf(pp.EmojiWarning, "Some features might stop working")
ids = append(ids, zone.ID)
case
"deleted": // archived, pending/moved for too long
Expand Down
4 changes: 2 additions & 2 deletions internal/api/cloudflare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func TestZoneOfDomain(t *testing.T) {
func(m *mocks.MockPP) {
gomock.InOrder(
m.EXPECT().Warningf(pp.EmojiWarning, "Zone %q is %q; your Cloudflare setup is incomplete", "test.org", "pending"), //nolint:lll
m.EXPECT().Warningf(pp.EmojiWarning, "Some features might stop working", "test.org", "pending"),
m.EXPECT().Warningf(pp.EmojiWarning, "Some features might stop working"),
)
},
},
Expand All @@ -424,7 +424,7 @@ func TestZoneOfDomain(t *testing.T) {
func(m *mocks.MockPP) {
gomock.InOrder(
m.EXPECT().Warningf(pp.EmojiWarning, "Zone %q is %q; your Cloudflare setup is incomplete", "test.org", "initializing"), //nolint:lll
m.EXPECT().Warningf(pp.EmojiWarning, "Some features might stop working", "test.org", "initializing"),
m.EXPECT().Warningf(pp.EmojiWarning, "Some features might stop working"),
)
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func ReadProvider(ppfmt pp.PP, key, keyDeprecated string, field *provider.Provid
ppfmt.Errorf(
pp.EmojiUserError,
`Parameter %s does not accept "cloudflare"; use "cloudflare.doh" or "cloudflare.trace"`,
key, key,
key,
)
return false
case "cloudflare.trace":
Expand Down
2 changes: 1 addition & 1 deletion internal/config/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func TestReadProvider(t *testing.T) {
m.EXPECT().Errorf(
pp.EmojiUserError,
`Parameter %s does not accept "cloudflare"; use "cloudflare.doh" or "cloudflare.trace"`,
key, key,
key,
)
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/monitor/healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (h *HealthChecks) Failure(ctx context.Context, ppfmt pp.PP) bool {

func (h *HealthChecks) ExitStatus(ctx context.Context, ppfmt pp.PP, code int) bool {
if code < 0 || code > 255 {
ppfmt.Errorf(pp.EmojiImpossible, "Exit code (%i) not within the range 0-255", code)
ppfmt.Errorf(pp.EmojiImpossible, "Exit code (%d) not within the range 0-255", code)
return false
}

Expand Down
2 changes: 1 addition & 1 deletion internal/monitor/healthchecks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func TestEndPoints(t *testing.T) {
nil,
false, false,
func(m *mocks.MockPP) {
m.EXPECT().Errorf(pp.EmojiImpossible, "Exit code (%i) not within the range 0-255", -1)
m.EXPECT().Errorf(pp.EmojiImpossible, "Exit code (%d) not within the range 0-255", -1)
},
},
} {
Expand Down

0 comments on commit 0740d61

Please sign in to comment.