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

Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
pull/12923/head
Oleksandr Redko 1 year ago committed by GitHub
parent 1ec6e407d0
commit 8e5f0387a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -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"`

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save