From cc157bfce42aa756e1cb5dcede90431c9fbe4692 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Sun, 25 Aug 2024 16:37:15 +1000 Subject: [PATCH] chore: upgrade go+golangci-lint --- .golangci.yml | 3 +++ bin/{.go-1.22.5.pkg => .go-1.23.0.pkg} | 0 ...lint-1.55.2.pkg => .golangci-lint-1.60.3.pkg} | 0 bin/go | 2 +- bin/gofmt | 2 +- bin/golangci-lint | 2 +- colour.go | 8 ++++---- formatters/json.go | 16 ++++++++++++---- serialise_test.go | 2 +- 9 files changed, 23 insertions(+), 12 deletions(-) rename bin/{.go-1.22.5.pkg => .go-1.23.0.pkg} (100%) rename bin/{.golangci-lint-1.55.2.pkg => .golangci-lint-1.60.3.pkg} (100%) diff --git a/.golangci.yml b/.golangci.yml index 668be37..7e98a22 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -51,6 +51,9 @@ linters: - musttag - depguard - goconst + - perfsprint + - mnd + - predeclared linters-settings: govet: diff --git a/bin/.go-1.22.5.pkg b/bin/.go-1.23.0.pkg similarity index 100% rename from bin/.go-1.22.5.pkg rename to bin/.go-1.23.0.pkg diff --git a/bin/.golangci-lint-1.55.2.pkg b/bin/.golangci-lint-1.60.3.pkg similarity index 100% rename from bin/.golangci-lint-1.55.2.pkg rename to bin/.golangci-lint-1.60.3.pkg diff --git a/bin/go b/bin/go index 5c26cb9..4602254 120000 --- a/bin/go +++ b/bin/go @@ -1 +1 @@ -.go-1.22.5.pkg \ No newline at end of file +.go-1.23.0.pkg \ No newline at end of file diff --git a/bin/gofmt b/bin/gofmt index 5c26cb9..4602254 120000 --- a/bin/gofmt +++ b/bin/gofmt @@ -1 +1 @@ -.go-1.22.5.pkg \ No newline at end of file +.go-1.23.0.pkg \ No newline at end of file diff --git a/bin/golangci-lint b/bin/golangci-lint index 5b19a9d..9fbbfeb 120000 --- a/bin/golangci-lint +++ b/bin/golangci-lint @@ -1 +1 @@ -.golangci-lint-1.55.2.pkg \ No newline at end of file +.golangci-lint-1.60.3.pkg \ No newline at end of file diff --git a/colour.go b/colour.go index b7fd6e0..e33d010 100644 --- a/colour.go +++ b/colour.go @@ -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 diff --git a/formatters/json.go b/formatters/json.go index f167bc0..436d3ce 100644 --- a/formatters/json.go +++ b/formatters/json.go @@ -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 })) diff --git a/serialise_test.go b/serialise_test.go index 558e5d4..e9a694c 100644 --- a/serialise_test.go +++ b/serialise_test.go @@ -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)