1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-25 21:39:02 +02:00

chore: upgrade go+golangci-lint

This commit is contained in:
Alec Thomas 2024-08-25 16:37:15 +10:00
parent 4d11870090
commit cc157bfce4
9 changed files with 23 additions and 12 deletions

View File

@ -51,6 +51,9 @@ linters:
- musttag
- depguard
- goconst
- perfsprint
- mnd
- predeclared
linters-settings:
govet:

2
bin/go
View File

@ -1 +1 @@
.go-1.22.5.pkg
.go-1.23.0.pkg

View File

@ -1 +1 @@
.go-1.22.5.pkg
.go-1.23.0.pkg

View File

@ -1 +1 @@
.golangci-lint-1.55.2.pkg
.golangci-lint-1.60.3.pkg

View File

@ -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.
@ -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

View File

@ -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)
@ -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
}))

View File

@ -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)