diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 68663a5f7..3b626461b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -33,6 +33,6 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # tag=v9.3.0 with: - version: v2.13.1 + version: v2.14.0 args: --output.text.print-linter-name=true --output.text.colors=true --timeout 10m working-directory: ${{matrix.working-directory}} diff --git a/.golangci.yml b/.golangci.yml index bd26bef8e..70e128563 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -38,6 +38,8 @@ linters: - nilerr - nolintlint - prealloc + - promlinter + - reassign - revive - staticcheck - tagliatelle diff --git a/cmd/controller-gen/main.go b/cmd/controller-gen/main.go index 8ee14dd7a..ef51725c6 100644 --- a/cmd/controller-gen/main.go +++ b/cmd/controller-gen/main.go @@ -249,7 +249,7 @@ func helpForLevels(mainOut io.Writer, errOut io.Writer, whichLevel int, reg *mar continue } contents := prettyhelp.MarkersDetails(fullDetail, cat.Category, cat.Markers) - if err := contents.WriteTo(errOut); err != nil { + if err := contents.Write(errOut); err != nil { return err } } @@ -259,7 +259,7 @@ func helpForLevels(mainOut io.Writer, errOut io.Writer, whichLevel int, reg *mar continue } contents := prettyhelp.MarkersSummary(cat.Category, cat.Markers) - if err := contents.WriteTo(errOut); err != nil { + if err := contents.Write(errOut); err != nil { return err } } diff --git a/cmd/helpgen/main.go b/cmd/helpgen/main.go index 3e1befda2..6527252ad 100644 --- a/cmd/helpgen/main.go +++ b/cmd/helpgen/main.go @@ -228,7 +228,7 @@ func usage() { continue } contents := prettyhelp.MarkersDetails(true, cat.Category, cat.Markers) - if err := contents.WriteTo(os.Stderr); err != nil { + if err := contents.Write(os.Stderr); err != nil { panic(err) } } @@ -239,7 +239,7 @@ func usage() { } markerInfo := help.ByCategory(reg, help.SortByCategory) contents := prettyhelp.MarkersDetails(true, "markers", markerInfo[0].Markers) - if err := contents.WriteTo(os.Stderr); err != nil { + if err := contents.Write(os.Stderr); err != nil { panic(err) } os.Exit(1) diff --git a/pkg/genall/help/pretty/print.go b/pkg/genall/help/pretty/print.go index a18738794..fe6f699ef 100644 --- a/pkg/genall/help/pretty/print.go +++ b/pkg/genall/help/pretty/print.go @@ -35,8 +35,8 @@ type Span interface { // VisualLength reports the "width" as perceived by the user on the terminal // (i.e. widest line, ignoring ANSI escape characters). VisualLength() int - // WriteTo writes the full span contents to the given writer. - WriteTo(io.Writer) error + // Write writes the full span contents to the given writer. + Write(io.Writer) error } // Table is a Span that writes its data in table form, with sizing controlled @@ -77,7 +77,7 @@ func (t *Table) SkipRow(contents Span) { t.cellsByRow = append(t.cellsByRow, []Span{contents}) } -func (t *Table) WriteTo(out io.Writer) error { +func (t *Table) Write(out io.Writer) error { if t.colSizes == nil { t.colSizes = t.Sizing.ColumnWidths() } @@ -88,7 +88,7 @@ func (t *Table) WriteTo(out io.Writer) error { colSize := t.colSizes[colInd] diff := colSize - cell.VisualLength() - if err := cell.WriteTo(out); err != nil { + if err := cell.Write(out); err != nil { return err } @@ -124,7 +124,7 @@ func (t *Table) VisualLength() int { type Text string func (t Text) VisualLength() int { return len(t) } -func (t Text) WriteTo(w io.Writer) error { +func (t Text) Write(w io.Writer) error { _, err := w.Write([]byte(t)) return err } @@ -136,9 +136,9 @@ type indented struct { } func (i *indented) VisualLength() int { return i.Content.VisualLength() } -func (i *indented) WriteTo(w io.Writer) error { +func (i *indented) Write(w io.Writer) error { var out bytes.Buffer - if err := i.Content.WriteTo(&out); err != nil { + if err := i.Content.Write(&out); err != nil { return err } @@ -185,7 +185,7 @@ func (f *fromWriter) VisualLength() int { } return len(f.cache) } -func (f *fromWriter) WriteTo(w io.Writer) error { +func (f *fromWriter) Write(w io.Writer) error { if f.cache != nil { if f.cacheError != nil { return f.cacheError @@ -219,7 +219,7 @@ type decorated struct { } func (d *decorated) VisualLength() int { return d.Contents.VisualLength() } -func (d *decorated) WriteTo(w io.Writer) error { +func (d *decorated) Write(w io.Writer) error { oldOut := color.Output color.Output = w defer func() { color.Output = oldOut }() @@ -227,7 +227,7 @@ func (d *decorated) WriteTo(w io.Writer) error { d.Attributes.Set() defer color.Unset() - return d.Contents.WriteTo(w) + return d.Contents.Write(w) } // SpanWriter is a span that contains multiple sub-spans. @@ -242,9 +242,9 @@ func (m *SpanWriter) VisualLength() int { } return res } -func (m *SpanWriter) WriteTo(w io.Writer) error { +func (m *SpanWriter) Write(w io.Writer) error { for _, span := range m.contents { - if err := span.WriteTo(w); err != nil { + if err := span.Write(w); err != nil { return err } } @@ -268,12 +268,12 @@ func (l *lines) VisualLength() int { } return l.content.VisualLength() } -func (l *lines) WriteTo(w io.Writer) error { +func (l *lines) Write(w io.Writer) error { if err := writePadding(w, linesPadding, l.amountBefore); err != nil { return err } if l.content != nil { - if err := l.content.WriteTo(w); err != nil { + if err := l.content.Write(w); err != nil { return err } }