Skip to content

Commit

Permalink
chore: upgrade go+golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Aug 25, 2024
1 parent 4d11870 commit cc157bf
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ linters:
- musttag
- depguard
- goconst
- perfsprint
- mnd
- predeclared

linters-settings:
govet:
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
2 changes: 1 addition & 1 deletion bin/golangci-lint
8 changes: 4 additions & 4 deletions colour.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func ParseColour(colour string) Colour {
if err != nil {
return 0
}
return Colour(n + 1)
return Colour(n + 1) //nolint:gosec
}

// MustParseColour is like ParseColour except it panics if the colour is invalid.
Expand All @@ -162,13 +162,13 @@ func (c Colour) String() string { return fmt.Sprintf("#%06x", int(c-1)) }
func (c Colour) GoString() string { return fmt.Sprintf("Colour(0x%06x)", int(c-1)) }

// Red component of colour.
func (c Colour) Red() uint8 { return uint8(((c - 1) >> 16) & 0xff) }
func (c Colour) Red() uint8 { return uint8(((c - 1) >> 16) & 0xff) } //nolint:gosec

// Green component of colour.
func (c Colour) Green() uint8 { return uint8(((c - 1) >> 8) & 0xff) }
func (c Colour) Green() uint8 { return uint8(((c - 1) >> 8) & 0xff) } //nolint:gosec

// Blue component of colour.
func (c Colour) Blue() uint8 { return uint8((c - 1) & 0xff) }
func (c Colour) Blue() uint8 { return uint8((c - 1) & 0xff) } //nolint:gosec

// Colours is an orderable set of colours.
type Colours []Colour
Expand Down
16 changes: 12 additions & 4 deletions formatters/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import (

// JSON formatter outputs the raw token structures as JSON.
var JSON = Register("json", chroma.FormatterFunc(func(w io.Writer, s *chroma.Style, it chroma.Iterator) error {
fmt.Fprintln(w, "[")
if _, err := fmt.Fprintln(w, "["); err != nil {
return err
}
i := 0
for t := it(); t != chroma.EOF; t = it() {
if i > 0 {
fmt.Fprintln(w, ",")
if _, err := fmt.Fprintln(w, ","); err != nil {
return err
}
}
i++
bytes, err := json.Marshal(t)
Expand All @@ -25,7 +29,11 @@ var JSON = Register("json", chroma.FormatterFunc(func(w io.Writer, s *chroma.Sty
return err
}
}
fmt.Fprintln(w)
fmt.Fprintln(w, "]")
if _, err := fmt.Fprintln(w); err != nil {
return err
}
if _, err := fmt.Fprintln(w, "]"); err != nil {
return err
}
return nil
}))
2 changes: 1 addition & 1 deletion serialise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestRulesSerialisation(t *testing.T) {
data = re.ReplaceAll(data, []byte(`/>`))
b := &bytes.Buffer{}
w := gzip.NewWriter(b)
fmt.Fprintln(w, string(data))
fmt.Fprintln(w, string(data)) //nolint:errcheck
w.Close()
actual := Rules{}
err = xml.Unmarshal(data, &actual)
Expand Down

0 comments on commit cc157bf

Please sign in to comment.