golangci-lint: enable makezero linter
cli/command/container/formatter_stats_test.go:339:11: append to slice `stats` with non-zero initialized length (makezero) stats = append(stats, entry) ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
18e911c958
commit
c1313a92a0
@ -42,6 +42,7 @@ linters:
|
|||||||
- govet
|
- govet
|
||||||
- importas # Enforces consistent import aliases.
|
- importas # Enforces consistent import aliases.
|
||||||
- ineffassign
|
- ineffassign
|
||||||
|
- makezero # Finds slice declarations with non-zero initial length.
|
||||||
- mirror # Detects wrong mirror patterns of bytes/strings usage.
|
- mirror # Detects wrong mirror patterns of bytes/strings usage.
|
||||||
- misspell # Detects commonly misspelled English words in comments.
|
- misspell # Detects commonly misspelled English words in comments.
|
||||||
- nakedret # Detects uses of naked returns.
|
- nakedret # Detects uses of naked returns.
|
||||||
|
@ -148,7 +148,7 @@ container2 -- --
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
stats := []StatsEntry{
|
entries := []StatsEntry{
|
||||||
{
|
{
|
||||||
Container: "container1",
|
Container: "container1",
|
||||||
CPUPercentage: 20,
|
CPUPercentage: 20,
|
||||||
@ -181,7 +181,7 @@ container2 -- --
|
|||||||
t.Run(string(tc.context.Format), func(t *testing.T) {
|
t.Run(string(tc.context.Format), func(t *testing.T) {
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
tc.context.Output = &out
|
tc.context.Output = &out
|
||||||
err := statsFormatWrite(tc.context, stats, "windows", false)
|
err := statsFormatWrite(tc.context, entries, "windows", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
assert.Error(t, err, tc.expected)
|
assert.Error(t, err, tc.expected)
|
||||||
} else {
|
} else {
|
||||||
@ -309,10 +309,10 @@ func TestContainerStatsContextWriteTrunc(t *testing.T) {
|
|||||||
|
|
||||||
func BenchmarkStatsFormat(b *testing.B) {
|
func BenchmarkStatsFormat(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
stats := genStats()
|
entries := genStats()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
for _, s := range stats {
|
for _, s := range entries {
|
||||||
_ = s.CPUPerc()
|
_ = s.CPUPerc()
|
||||||
_ = s.MemUsage()
|
_ = s.MemUsage()
|
||||||
_ = s.MemPerc()
|
_ = s.MemPerc()
|
||||||
@ -335,9 +335,9 @@ func genStats() []statsContext {
|
|||||||
NetworkTx: 987.654321,
|
NetworkTx: 987.654321,
|
||||||
PidsCurrent: 123456789,
|
PidsCurrent: 123456789,
|
||||||
}}
|
}}
|
||||||
stats := make([]statsContext, 100)
|
entries := make([]statsContext, 0, 100)
|
||||||
for i := 0; i < 100; i++ {
|
for range 100 {
|
||||||
stats = append(stats, entry)
|
entries = append(entries, entry)
|
||||||
}
|
}
|
||||||
return stats
|
return entries
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user