Skip to content

Commit 888df09

Browse files
committed
linting: address assorted issues found by gocritic
internal/test/builders/config.go:36:15: captLocal: `ID' should not be capitalized (gocritic) func ConfigID(ID string) func(config *swarm.Config) { ^ internal/test/builders/secret.go:45:15: captLocal: `ID' should not be capitalized (gocritic) func SecretID(ID string) func(secret *swarm.Secret) { ^ internal/test/builders/service.go:21:16: captLocal: `ID' should not be capitalized (gocritic) func ServiceID(ID string) func(*swarm.Service) { ^ cli/command/image/formatter_history.go:100:15: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(c.h.CreatedBy, "\t", " ", -1)` (gocritic) createdBy := strings.Replace(c.h.CreatedBy, "\t", " ", -1) ^ e2e/image/push_test.go:246:34: badCall: suspicious Join on 1 argument (gocritic) assert.NilError(t, os.RemoveAll(filepath.Join(dir.Join("trust")))) ^ e2e/image/push_test.go:313:34: badCall: suspicious Join on 1 argument (gocritic) assert.NilError(t, os.RemoveAll(filepath.Join(dir.Join("trust")))) ^ cli/config/configfile/file_test.go:185:2: assignOp: replace `c.GetAllCallCount = c.GetAllCallCount + 1` with `c.GetAllCallCount++` (gocritic) c.GetAllCallCount = c.GetAllCallCount + 1 ^ cli/command/context/inspect_test.go:20:58: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(si.MetadataPath, `\`, `\\`, -1)` (gocritic) expected = strings.Replace(expected, "<METADATA_PATH>", strings.Replace(si.MetadataPath, `\`, `\\`, -1), 1) ^ cli/command/context/inspect_test.go:21:53: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(si.TLSPath, `\`, `\\`, -1)` (gocritic) expected = strings.Replace(expected, "<TLS_PATH>", strings.Replace(si.TLSPath, `\`, `\\`, -1), 1) ^ cli/command/container/formatter_stats.go:119:46: captLocal: `Stats' should not be capitalized (gocritic) func statsFormatWrite(ctx formatter.Context, Stats []StatsEntry, osType string, trunc bool) error { ^ cli/command/container/stats_helpers.go:209:4: assignOp: replace `blkRead = blkRead + bioEntry.Value` with `blkRead += bioEntry.Value` (gocritic) blkRead = blkRead + bioEntry.Value ^ cli/command/container/stats_helpers.go:211:4: assignOp: replace `blkWrite = blkWrite + bioEntry.Value` with `blkWrite += bioEntry.Value` (gocritic) blkWrite = blkWrite + bioEntry.Value ^ cli/command/registry/formatter_search.go:67:10: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(c.s.Description, "\n", " ", -1)` (gocritic) desc := strings.Replace(c.s.Description, "\n", " ", -1) ^ cli/command/registry/formatter_search.go:68:9: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(desc, "\r", " ", -1)` (gocritic) desc = strings.Replace(desc, "\r", " ", -1) ^ cli/command/service/list_test.go:164:5: assignOp: replace `tc.doc = tc.doc + " with quiet"` with `tc.doc += " with quiet"` (gocritic) tc.doc = tc.doc + " with quiet" ^ cli/command/service/progress/progress.go:274:11: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(errMsg, "\n", " ", -1)` (gocritic) errMsg = strings.Replace(errMsg, "\n", " ", -1) ^ cli/manifest/store/store.go:153:9: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(fileName, "/", "_", -1)` (gocritic) return strings.Replace(fileName, "/", "_", -1) ^ cli/manifest/store/store.go:152:14: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(ref, ":", "-", -1)` (gocritic) fileName := strings.Replace(ref, ":", "-", -1) ^ cli/command/plugin/formatter.go:79:10: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(c.p.Config.Description, "\n", "", -1)` (gocritic) desc := strings.Replace(c.p.Config.Description, "\n", "", -1) ^ cli/command/plugin/formatter.go:80:9: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(desc, "\r", "", -1)` (gocritic) desc = strings.Replace(desc, "\r", "", -1) ^ cli/compose/convert/service.go:642:23: captLocal: `DNS' should not be capitalized (gocritic) func convertDNSConfig(DNS []string, DNSSearch []string) *swarm.DNSConfig { ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent d0dee3c commit 888df09

17 files changed

Lines changed: 31 additions & 34 deletions

File tree

cli/command/container/formatter_stats.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ func NewStats(container string) *Stats {
116116
}
117117

118118
// statsFormatWrite renders the context for a list of containers statistics
119-
func statsFormatWrite(ctx formatter.Context, Stats []StatsEntry, osType string, trunc bool) error {
119+
func statsFormatWrite(ctx formatter.Context, stats []StatsEntry, osType string, trunc bool) error {
120120
render := func(format func(subContext formatter.SubContext) error) error {
121-
for _, cstats := range Stats {
121+
for _, cstats := range stats {
122122
statsCtx := &statsContext{
123123
s: cstats,
124124
os: osType,

cli/command/container/stats_helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ func calculateBlockIO(blkio types.BlkioStats) (uint64, uint64) {
206206
}
207207
switch bioEntry.Op[0] {
208208
case 'r', 'R':
209-
blkRead = blkRead + bioEntry.Value
209+
blkRead += bioEntry.Value
210210
case 'w', 'W':
211-
blkWrite = blkWrite + bioEntry.Value
211+
blkWrite += bioEntry.Value
212212
}
213213
}
214214
return blkRead, blkWrite

cli/command/context/inspect_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestInspect(t *testing.T) {
1717
}))
1818
expected := string(golden.Get(t, "inspect.golden"))
1919
si := cli.ContextStore().GetStorageInfo("current")
20-
expected = strings.Replace(expected, "<METADATA_PATH>", strings.Replace(si.MetadataPath, `\`, `\\`, -1), 1)
21-
expected = strings.Replace(expected, "<TLS_PATH>", strings.Replace(si.TLSPath, `\`, `\\`, -1), 1)
20+
expected = strings.Replace(expected, "<METADATA_PATH>", strings.ReplaceAll(si.MetadataPath, `\`, `\\`), 1)
21+
expected = strings.Replace(expected, "<TLS_PATH>", strings.ReplaceAll(si.TLSPath, `\`, `\\`), 1)
2222
assert.Equal(t, cli.OutBuffer().String(), expected)
2323
}

cli/command/image/formatter_history.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (c *historyContext) CreatedSince() string {
9797
}
9898

9999
func (c *historyContext) CreatedBy() string {
100-
createdBy := strings.Replace(c.h.CreatedBy, "\t", " ", -1)
100+
createdBy := strings.ReplaceAll(c.h.CreatedBy, "\t", " ")
101101
if c.trunc {
102102
return formatter.Ellipsis(createdBy, 45)
103103
}

cli/command/plugin/formatter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ func (c *pluginContext) Name() string {
7676
}
7777

7878
func (c *pluginContext) Description() string {
79-
desc := strings.Replace(c.p.Config.Description, "\n", "", -1)
80-
desc = strings.Replace(desc, "\r", "", -1)
79+
desc := strings.ReplaceAll(c.p.Config.Description, "\n", "")
80+
desc = strings.ReplaceAll(desc, "\r", "")
8181
if c.trunc {
8282
desc = formatter.Ellipsis(desc, 45)
8383
}

cli/command/registry/formatter_search.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ func (c *searchContext) Name() string {
6464
}
6565

6666
func (c *searchContext) Description() string {
67-
desc := strings.Replace(c.s.Description, "\n", " ", -1)
68-
desc = strings.Replace(desc, "\r", " ", -1)
67+
desc := strings.ReplaceAll(c.s.Description, "\n", " ")
68+
desc = strings.ReplaceAll(desc, "\r", " ")
6969
if c.trunc {
7070
desc = formatter.Ellipsis(desc, 45)
7171
}

cli/command/service/list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func TestServiceListServiceStatus(t *testing.T) {
161161
for _, tc := range tests {
162162
if quiet {
163163
tc.withQuiet = quiet
164-
tc.doc = tc.doc + " with quiet"
164+
tc.doc += " with quiet"
165165
}
166166
matrix = append(matrix, tc)
167167
}

cli/command/service/progress/progress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func writeOverallProgress(progressOut progress.Output, numerator, denominator in
271271

272272
func truncError(errMsg string) string {
273273
// Remove newlines from the error, which corrupt the output.
274-
errMsg = strings.Replace(errMsg, "\n", " ", -1)
274+
errMsg = strings.ReplaceAll(errMsg, "\n", " ")
275275

276276
// Limit the length to 75 characters, so that even on narrow terminals
277277
// this will not overflow to the next line.

cli/compose/convert/service.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,11 @@ func convertDeployMode(mode string, replicas *uint64) (swarm.ServiceMode, error)
639639
return serviceMode, nil
640640
}
641641

642-
func convertDNSConfig(DNS []string, DNSSearch []string) *swarm.DNSConfig {
643-
if DNS != nil || DNSSearch != nil {
642+
func convertDNSConfig(dns []string, dnsSearch []string) *swarm.DNSConfig {
643+
if dns != nil || dnsSearch != nil {
644644
return &swarm.DNSConfig{
645-
Nameservers: DNS,
646-
Search: DNSSearch,
645+
Nameservers: dns,
646+
Search: dnsSearch,
647647
}
648648
}
649649
return nil

cli/config/configfile/file_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (c *mockNativeStore) Get(registryHostname string) (types.AuthConfig, error)
182182
}
183183

184184
func (c *mockNativeStore) GetAll() (map[string]types.AuthConfig, error) {
185-
c.GetAllCallCount = c.GetAllCallCount + 1
185+
c.GetAllCallCount++
186186
return c.authConfigs, nil
187187
}
188188

0 commit comments

Comments
 (0)