ci(lint): enable nolintlint and remove redundant comments (#12926)

Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
This commit is contained in:
Oleksandr Redko 2023-10-31 13:35:13 +02:00 committed by GitHub
parent 1ec6e407d0
commit 8e5f0387a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 29 additions and 48 deletions

View file

@ -18,6 +18,7 @@ linters:
- gofumpt
- goimports
- misspell
- nolintlint
- predeclared
- revive
- unconvert

View file

@ -12,7 +12,6 @@
// limitations under the License.
// The main package for the Prometheus server executable.
// nolint:revive // Many unsued function arguments in this file by design.
package main
import (

View file

@ -44,7 +44,7 @@ func sortSamples(samples []backfillSample) {
})
}
func queryAllSeries(t testing.TB, q storage.Querier, expectedMinTime, expectedMaxTime int64) []backfillSample { // nolint:revive
func queryAllSeries(t testing.TB, q storage.Querier, expectedMinTime, expectedMaxTime int64) []backfillSample {
ss := q.Select(context.Background(), false, nil, labels.MustNewMatcher(labels.MatchRegexp, "", ".*"))
samples := []backfillSample{}
for ss.Next() {

View file

@ -411,7 +411,6 @@ func checkExperimental(f bool) {
}
}
// nolint:revive
var lintError = fmt.Errorf("lint error")
type lintConfig struct {

View file

@ -35,7 +35,7 @@ type mockQueryRangeAPI struct {
samples model.Matrix
}
func (mockAPI mockQueryRangeAPI) QueryRange(_ context.Context, query string, r v1.Range, opts ...v1.Option) (model.Value, v1.Warnings, error) { // nolint:revive
func (mockAPI mockQueryRangeAPI) QueryRange(_ context.Context, query string, r v1.Range, opts ...v1.Option) (model.Value, v1.Warnings, error) {
return mockAPI.samples, v1.Warnings{}, nil
}

View file

@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// nolint:revive // Many legitimately empty blocks in this file.
package kubernetes
import (

View file

@ -190,7 +190,7 @@ func (e *EndpointSlice) Run(ctx context.Context, ch chan<- []*targetgroup.Group)
}
go func() {
for e.process(ctx, ch) { // nolint:revive
for e.process(ctx, ch) {
}
}()

View file

@ -88,7 +88,7 @@ func (i *Ingress) Run(ctx context.Context, ch chan<- []*targetgroup.Group) {
}
go func() {
for i.process(ctx, ch) { // nolint:revive
for i.process(ctx, ch) {
}
}()

View file

@ -96,7 +96,7 @@ func (n *Node) Run(ctx context.Context, ch chan<- []*targetgroup.Group) {
}
go func() {
for n.process(ctx, ch) { // nolint:revive
for n.process(ctx, ch) {
}
}()

View file

@ -131,7 +131,7 @@ func (p *Pod) Run(ctx context.Context, ch chan<- []*targetgroup.Group) {
}
go func() {
for p.process(ctx, ch) { // nolint:revive
for p.process(ctx, ch) {
}
}()

View file

@ -91,7 +91,7 @@ func (s *Service) Run(ctx context.Context, ch chan<- []*targetgroup.Group) {
}
go func() {
for s.process(ctx, ch) { // nolint:revive
for s.process(ctx, ch) {
}
}()

View file

@ -193,7 +193,7 @@ func (d *Discovery) Run(ctx context.Context, ch chan<- []*targetgroup.Group) {
}
for _, pathUpdate := range d.pathUpdates {
// Drain event channel in case the treecache leaks goroutines otherwise.
for range pathUpdate { // nolint:revive
for range pathUpdate {
}
}
d.conn.Close()

View file

@ -2025,7 +2025,7 @@ func (ev *evaluator) matrixIterSlice(
// (b) the number of samples is relatively small.
// so a linear search will be as fast as a binary search.
var drop int
for drop = 0; floats[drop].T < mint; drop++ { // nolint:revive
for drop = 0; floats[drop].T < mint; drop++ {
}
ev.currentSamples -= drop
copy(floats, floats[drop:])
@ -2047,7 +2047,7 @@ func (ev *evaluator) matrixIterSlice(
// (b) the number of samples is relatively small.
// so a linear search will be as fast as a binary search.
var drop int
for drop = 0; histograms[drop].T < mint; drop++ { // nolint:revive
for drop = 0; histograms[drop].T < mint; drop++ {
}
copy(histograms, histograms[drop:])
histograms = histograms[:len(histograms)-drop]

View file

@ -1656,7 +1656,6 @@ func TestRecoverEvaluatorRuntime(t *testing.T) {
// Cause a runtime panic.
var a []int
//nolint:govet
a[123] = 1
}

View file

@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// nolint:revive // Many unsued function arguments in this file by design.
package promql
import (

View file

@ -55,7 +55,6 @@ type Statement interface {
Node
// PromQLStmt ensures that no other type accidentally implements the interface
// nolint:unused
PromQLStmt()
}

View file

@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// nolint:revive // Many legitimately empty blocks in this file.
package parser
import (

View file

@ -72,7 +72,6 @@ func WithFunctions(functions map[string]*Function) Opt {
}
// NewParser returns a new parser.
// nolint:revive
func NewParser(input string, opts ...Opt) *parser {
p := parserPool.Get().(*parser)
@ -660,9 +659,9 @@ func (p *parser) checkAST(node Node) (typ ValueType) {
// This is made a function instead of a variable, so it is lazily evaluated on demand.
opRange := func() (r posrange.PositionRange) {
// Remove whitespace at the beginning and end of the range.
for r.Start = n.LHS.PositionRange().End; isSpace(rune(p.lex.input[r.Start])); r.Start++ { // nolint:revive
for r.Start = n.LHS.PositionRange().End; isSpace(rune(p.lex.input[r.Start])); r.Start++ {
}
for r.End = n.RHS.PositionRange().Start - 1; isSpace(rune(p.lex.input[r.End])); r.End-- { // nolint:revive
for r.End = n.RHS.PositionRange().Start - 1; isSpace(rune(p.lex.input[r.End])); r.End-- {
}
return
}

View file

@ -4036,7 +4036,6 @@ func TestRecoverParserRuntime(t *testing.T) {
defer p.recover(&err)
// Cause a runtime panic.
var a []int
//nolint:govet
a[123] = 1
}

View file

@ -145,9 +145,7 @@ func (t *Target) SetMetadataStore(s MetricMetadataStore) {
func (t *Target) hash() uint64 {
h := fnv.New64a()
//nolint: errcheck
h.Write([]byte(fmt.Sprintf("%016d", t.labels.Hash())))
//nolint: errcheck
h.Write([]byte(t.URL().String()))
return h.Sum64()

View file

@ -211,7 +211,7 @@ func BenchmarkBufferedSeriesIterator(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for it.Next() != chunkenc.ValNone { // nolint:revive
for it.Next() != chunkenc.ValNone {
// Scan everything.
}
require.NoError(b, it.Err())

View file

@ -112,7 +112,7 @@ func BenchmarkMemoizedSeriesIterator(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for it.Next() != chunkenc.ValNone { // nolint:revive
for it.Next() != chunkenc.ValNone {
// Scan everything.
}
require.NoError(b, it.Err())

View file

@ -62,7 +62,7 @@ type OAuthConfig struct {
}
// AzureADConfig is used to store the config values.
type AzureADConfig struct { // nolint:revive
type AzureADConfig struct {
// ManagedIdentity is the managed identity that is being used to authenticate.
ManagedIdentity *ManagedIdentityConfig `yaml:"managed_identity,omitempty"`

View file

@ -181,7 +181,7 @@ func NewTemplateExpander(
return html_template.HTML(text)
},
"match": regexp.MatchString,
"title": strings.Title, // nolint:staticcheck
"title": strings.Title, //nolint:staticcheck
"toUpper": strings.ToUpper,
"toLower": strings.ToLower,
"graphLink": strutil.GraphLinkForExpression,

View file

@ -103,7 +103,7 @@ func (c *FloatHistogramChunk) Appender() (Appender, error) {
// To get an appender, we must know the state it would have if we had
// appended all existing data from scratch. We iterate through the end
// and populate via the iterator's state.
for it.Next() == ValFloatHistogram { // nolint:revive
for it.Next() == ValFloatHistogram {
}
if err := it.Err(); err != nil {
return nil, err

View file

@ -157,7 +157,7 @@ func TestFloatHistogramChunkSameBuckets(t *testing.T) {
// 3. Now recycle an iterator that was never used to access anything.
itX := c.Iterator(nil)
for itX.Next() == ValFloatHistogram { // nolint:revive
for itX.Next() == ValFloatHistogram {
// Just iterate through without accessing anything.
}
it3 := c.iterator(itX)

View file

@ -114,7 +114,7 @@ func (c *HistogramChunk) Appender() (Appender, error) {
// To get an appender, we must know the state it would have if we had
// appended all existing data from scratch. We iterate through the end
// and populate via the iterator's state.
for it.Next() == ValHistogram { // nolint:revive
for it.Next() == ValHistogram {
}
if err := it.Err(); err != nil {
return nil, err

View file

@ -162,7 +162,7 @@ func TestHistogramChunkSameBuckets(t *testing.T) {
// 3. Now recycle an iterator that was never used to access anything.
itX := c.Iterator(nil)
for itX.Next() == ValHistogram { // nolint:revive
for itX.Next() == ValHistogram {
// Just iterate through without accessing anything.
}
it3 := c.iterator(itX)

View file

@ -99,7 +99,7 @@ func (c *XORChunk) Appender() (Appender, error) {
// To get an appender we must know the state it would have if we had
// appended all existing data from scratch.
// We iterate through the end and populate via the iterator's state.
for it.Next() != ValNone { // nolint:revive
for it.Next() != ValNone {
}
if err := it.Err(); err != nil {
return nil, err

View file

@ -25,7 +25,7 @@ import (
type multiError []error
// NewMulti returns multiError with provided errors added if not nil.
func NewMulti(errs ...error) multiError { // nolint:revive
func NewMulti(errs ...error) multiError {
m := multiError{}
m.Add(errs...)
return m

View file

@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// nolint:revive // Many legitimately empty blocks in this file.
package tsdb
import (

View file

@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// nolint:revive // Many legitimately empty blocks in this file.
package tsdb
import (

View file

@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// nolint:revive // Many unused function arguments in this file by design.
package tsdb
import (

View file

@ -267,7 +267,7 @@ func BenchmarkQuerierSelect(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
ss := q.Select(context.Background(), sorted, nil, matcher)
for ss.Next() { // nolint:revive
for ss.Next() {
}
require.NoError(b, ss.Err())
}

View file

@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// nolint:revive // Many unsued function arguments in this file by design.
package tsdb
import (

View file

@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// nolint:revive // Many unsued function arguments in this file by design.
package tsdb
import (

View file

@ -541,7 +541,7 @@ func TestReaderData(t *testing.T) {
require.NoError(t, err)
reader := fn(sr)
for reader.Next() { // nolint:revive
for reader.Next() {
}
require.NoError(t, reader.Err())

View file

@ -971,7 +971,6 @@ type segmentBufReader struct {
off int // Offset of read data into current segment.
}
// nolint:revive // TODO: Consider exporting segmentBufReader
func NewSegmentBufReader(segs ...*Segment) *segmentBufReader {
if len(segs) == 0 {
return &segmentBufReader{}
@ -983,7 +982,6 @@ func NewSegmentBufReader(segs ...*Segment) *segmentBufReader {
}
}
// nolint:revive
func NewSegmentBufReaderWithOffset(offset int, segs ...*Segment) (sbr *segmentBufReader, err error) {
if offset == 0 || len(segs) == 0 {
return NewSegmentBufReader(segs...), nil

View file

@ -164,7 +164,7 @@ func TestWALRepair_ReadingError(t *testing.T) {
sr := NewSegmentBufReader(s)
require.NoError(t, err)
r := NewReader(sr)
for r.Next() { // nolint:revive
for r.Next() {
}
// Close the segment so we don't break things on Windows.

View file

@ -91,7 +91,6 @@ func (a Annotations) AsStrings(query string, maxAnnos int) []string {
return arr
}
//nolint:revive // Ignore ST1012
var (
// Currently there are only 2 types, warnings and info.
// For now, info are visually identical with warnings as we have not updated

View file

@ -116,7 +116,7 @@ func (tc *ZookeeperTreeCache) Stop() {
tc.stop <- struct{}{}
go func() {
// Drain tc.head.events so that go routines can make progress and exit.
for range tc.head.events { // nolint:revive
for range tc.head.events {
}
}()
go func() {

View file

@ -149,13 +149,13 @@ func BenchmarkSyncPoolNewPointer(b *testing.B) {
// Warmup
item := pool.Get().(*[]byte)
pool.Put(item) //nolint:staticcheck // This allocates.
pool.Put(item)
b.ResetTimer()
for i := 0; i < b.N; i++ {
item := pool.Get().(*[]byte)
buf := *item
pool.Put(&buf) //nolint:staticcheck // New pointer.
pool.Put(&buf)
}
}

View file

@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// nolint:revive // Many unsued function arguments in this file by design.
package v1
import (