Skip to content

Commit 7cddb41

Browse files
committed
Fix golangci-lint findings
Fix findings by golangci-lint run.
1 parent 10c9fb7 commit 7cddb41

File tree

5 files changed

+52
-52
lines changed

5 files changed

+52
-52
lines changed

box_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ DimGray{╵}
188188
It("should create a box using a reader", func() {
189189
r, w := io.Pipe()
190190
go func() {
191-
w.Write([]byte("multi\n"))
192-
w.Write([]byte("line\n"))
193-
w.Write([]byte("content\n"))
194-
w.Close()
191+
_, _ = w.Write([]byte("multi\n"))
192+
_, _ = w.Write([]byte("line\n"))
193+
_, _ = w.Write([]byte("content\n"))
194+
_ = w.Close()
195195
}()
196196

197197
var buf bytes.Buffer

errors_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ var _ = Describe("error rendering", func() {
9090
w.Close()
9191

9292
var buf bytes.Buffer
93-
io.Copy(&buf, r)
93+
_, err = io.Copy(&buf, r)
94+
Expect(err).ToNot(HaveOccurred())
9495

9596
return buf.String()
9697
}

go.sum

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/
7979
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
8080
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
8181
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
82-
golang.org/x/net v0.0.0-20210917163549-3c21e5b27794 h1:pOaRGvJk+MpHIfe37zcmbwolJplrAmLKmvggJVLkYl8=
83-
golang.org/x/net v0.0.0-20210917163549-3c21e5b27794/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
8482
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba h1:6u6sik+bn/y7vILcYkK3iwTBWN7WtBvB0+SZswQnbf8=
8583
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
8684
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -102,14 +100,11 @@ golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7w
102100
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
103101
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
104102
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
105-
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
106103
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
107104
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
108105
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
109106
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
110107
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
111-
golang.org/x/term v0.0.0-20210916214954-140adaaadfaf h1:Ihq/mm/suC88gF8WFcVwk+OV6Tq+wyA1O0E5UEvDglI=
112-
golang.org/x/term v0.0.0-20210916214954-140adaaadfaf/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
113108
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
114109
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
115110
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

output_json.go

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -293,73 +293,77 @@ func (p *OutputProcessor) neatJSONofNode(prefix string, node *yamlv3.Node) error
293293

294294
func (p *OutputProcessor) neatJSONofYAMLMapSlice(prefix string, mapslice yamlv2.MapSlice) error {
295295
if len(mapslice) == 0 {
296-
p.out.WriteString(p.colorize("{}", "emptyStructures"))
296+
_, _ = p.out.WriteString(p.colorize("{}", "emptyStructures"))
297297
return nil
298298
}
299299

300-
p.out.WriteString(bunt.Style("{", bunt.Bold()))
301-
p.out.WriteString("\n")
300+
_, _ = p.out.WriteString(bunt.Style("{", bunt.Bold()))
301+
_, _ = p.out.WriteString("\n")
302302

303303
for idx, mapitem := range mapslice {
304304
keyString := fmt.Sprintf("\"%v\": ", mapitem.Key)
305305

306-
p.out.WriteString(prefix + p.prefixAdd())
307-
p.out.WriteString(p.colorize(keyString, "keyColor"))
306+
_, _ = p.out.WriteString(prefix + p.prefixAdd())
307+
_, _ = p.out.WriteString(p.colorize(keyString, "keyColor"))
308308

309309
if p.isScalar(mapitem.Value) {
310-
p.neatJSONofScalar("", mapitem.Value)
310+
if err := p.neatJSONofScalar("", mapitem.Value); err != nil {
311+
return err
312+
}
311313

312314
} else {
313315
p.neatJSON(prefix+p.prefixAdd(), mapitem.Value)
314316
}
315317

316318
if idx < len(mapslice)-1 {
317-
p.out.WriteString(",")
319+
_, _ = p.out.WriteString(",")
318320
}
319321

320-
p.out.WriteString("\n")
322+
_, _ = p.out.WriteString("\n")
321323
}
322324

323-
p.out.WriteString(prefix)
324-
p.out.WriteString(bunt.Style("}", bunt.Bold()))
325+
_, _ = p.out.WriteString(prefix)
326+
_, _ = p.out.WriteString(bunt.Style("}", bunt.Bold()))
325327

326328
return nil
327329
}
328330

329331
func (p *OutputProcessor) neatJSONofSlice(prefix string, list []interface{}) error {
330332
if len(list) == 0 {
331-
p.out.WriteString(p.colorize("[]", "emptyStructures"))
333+
_, _ = p.out.WriteString(p.colorize("[]", "emptyStructures"))
332334
return nil
333335
}
334336

335-
p.out.WriteString(bunt.Style("[", bunt.Bold()))
336-
p.out.WriteString("\n")
337+
_, _ = p.out.WriteString(bunt.Style("[", bunt.Bold()))
338+
_, _ = p.out.WriteString("\n")
337339

338340
for idx, value := range list {
339341
if p.isScalar(value) {
340-
p.neatJSONofScalar(prefix+p.prefixAdd(), value)
342+
if err := p.neatJSONofScalar(prefix+p.prefixAdd(), value); err != nil {
343+
return err
344+
}
341345

342346
} else {
343-
p.out.WriteString(prefix + p.prefixAdd())
347+
_, _ = p.out.WriteString(prefix + p.prefixAdd())
344348
p.neatJSON(prefix+p.prefixAdd(), value)
345349
}
346350

347351
if idx < len(list)-1 {
348-
p.out.WriteString(",")
352+
_, _ = p.out.WriteString(",")
349353
}
350354

351-
p.out.WriteString("\n")
355+
_, _ = p.out.WriteString("\n")
352356
}
353357

354-
p.out.WriteString(prefix)
355-
p.out.WriteString(bunt.Style("]", bunt.Bold()))
358+
_, _ = p.out.WriteString(prefix)
359+
_, _ = p.out.WriteString(bunt.Style("]", bunt.Bold()))
356360

357361
return nil
358362
}
359363

360364
func (p *OutputProcessor) neatJSONofScalar(prefix string, obj interface{}) error {
361365
if obj == nil {
362-
p.out.WriteString(p.colorize("null", "nullColor"))
366+
_, _ = p.out.WriteString(p.colorize("null", "nullColor"))
363367
return nil
364368
}
365369

@@ -370,13 +374,13 @@ func (p *OutputProcessor) neatJSONofScalar(prefix string, obj interface{}) error
370374

371375
color := p.determineColorByType(obj)
372376

373-
p.out.WriteString(prefix)
377+
_, _ = p.out.WriteString(prefix)
374378
parts := strings.Split(string(data), "\\n")
375379
for idx, part := range parts {
376-
p.out.WriteString(p.colorize(part, color))
380+
_, _ = p.out.WriteString(p.colorize(part, color))
377381

378382
if idx < len(parts)-1 {
379-
p.out.WriteString(p.colorize("\\n", "emptyStructures"))
383+
_, _ = p.out.WriteString(p.colorize("\\n", "emptyStructures"))
380384
}
381385
}
382386

output_yaml.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,44 +79,44 @@ func (p *OutputProcessor) neatYAML(prefix string, skipIndentOnFirstLine bool, ob
7979
func (p *OutputProcessor) neatYAMLofMapSlice(prefix string, skipIndentOnFirstLine bool, mapslice yamlv2.MapSlice) error {
8080
for i, mapitem := range mapslice {
8181
if !skipIndentOnFirstLine || i > 0 {
82-
p.out.WriteString(prefix)
82+
_, _ = p.out.WriteString(prefix)
8383
}
8484

8585
keyString := fmt.Sprintf("%v:", mapitem.Key)
8686
if p.boldKeys {
8787
keyString = bunt.Style(keyString, bunt.Bold())
8888
}
8989

90-
p.out.WriteString(p.colorize(keyString, "keyColor"))
90+
_, _ = p.out.WriteString(p.colorize(keyString, "keyColor"))
9191

9292
switch mapitem.Value.(type) {
9393
case yamlv2.MapSlice:
9494
if len(mapitem.Value.(yamlv2.MapSlice)) == 0 {
95-
p.out.WriteString(" ")
96-
p.out.WriteString(p.colorize("{}", "emptyStructures"))
97-
p.out.WriteString("\n")
95+
_, _ = p.out.WriteString(" ")
96+
_, _ = p.out.WriteString(p.colorize("{}", "emptyStructures"))
97+
_, _ = p.out.WriteString("\n")
9898

9999
} else {
100-
p.out.WriteString("\n")
100+
_, _ = p.out.WriteString("\n")
101101
if err := p.neatYAMLofMapSlice(prefix+p.prefixAdd(), false, mapitem.Value.(yamlv2.MapSlice)); err != nil {
102102
return err
103103
}
104104
}
105105

106106
case []interface{}:
107107
if len(mapitem.Value.([]interface{})) == 0 {
108-
p.out.WriteString(" ")
109-
p.out.WriteString(p.colorize("[]", "emptyStructures"))
110-
p.out.WriteString("\n")
108+
_, _ = p.out.WriteString(" ")
109+
_, _ = p.out.WriteString(p.colorize("[]", "emptyStructures"))
110+
_, _ = p.out.WriteString("\n")
111111
} else {
112-
p.out.WriteString("\n")
112+
_, _ = p.out.WriteString("\n")
113113
if err := p.neatYAMLofSlice(prefix, false, mapitem.Value.([]interface{})); err != nil {
114114
return err
115115
}
116116
}
117117

118118
default:
119-
p.out.WriteString(" ")
119+
_, _ = p.out.WriteString(" ")
120120
if err := p.neatYAMLofScalar(prefix, false, mapitem.Value); err != nil {
121121
return err
122122
}
@@ -128,9 +128,9 @@ func (p *OutputProcessor) neatYAMLofMapSlice(prefix string, skipIndentOnFirstLin
128128

129129
func (p *OutputProcessor) neatYAMLofSlice(prefix string, skipIndentOnFirstLine bool, list []interface{}) error {
130130
for _, entry := range list {
131-
p.out.WriteString(prefix)
132-
p.out.WriteString(p.colorize("-", "dashColor"))
133-
p.out.WriteString(" ")
131+
_, _ = p.out.WriteString(prefix)
132+
_, _ = p.out.WriteString(p.colorize("-", "dashColor"))
133+
_, _ = p.out.WriteString(" ")
134134
if err := p.neatYAML(prefix+p.prefixAdd(), true, entry); err != nil {
135135
return err
136136
}
@@ -142,8 +142,8 @@ func (p *OutputProcessor) neatYAMLofSlice(prefix string, skipIndentOnFirstLine b
142142
func (p *OutputProcessor) neatYAMLofScalar(prefix string, skipIndentOnFirstLine bool, obj interface{}) error {
143143
// Process nil values immediately and return afterwards
144144
if obj == nil {
145-
p.out.WriteString(p.colorize("null", "nullColor"))
146-
p.out.WriteString("\n")
145+
_, _ = p.out.WriteString(p.colorize("null", "nullColor"))
146+
_, _ = p.out.WriteString("\n")
147147
return nil
148148
}
149149

@@ -159,11 +159,11 @@ func (p *OutputProcessor) neatYAMLofScalar(prefix string, skipIndentOnFirstLine
159159
// Cast byte slice to string, remove trailing newlines, split into lines
160160
for i, line := range strings.Split(strings.TrimSpace(string(data)), "\n") {
161161
if i > 0 {
162-
p.out.WriteString(prefix)
162+
_, _ = p.out.WriteString(prefix)
163163
}
164164

165-
p.out.WriteString(p.colorize(line, color))
166-
p.out.WriteString("\n")
165+
_, _ = p.out.WriteString(p.colorize(line, color))
166+
_, _ = p.out.WriteString("\n")
167167
}
168168

169169
return nil

0 commit comments

Comments
 (0)