Browse Source

Fix golint issues.

Signed-off-by: Ben Kochie <superq@gmail.com>
pull/7037/head
Ben Kochie 5 years ago
parent
commit
269e7c8091
No known key found for this signature in database
GPG Key ID: C646B23C9E3245F1
  1. 2
      cmd/prometheus/main.go
  2. 6
      pkg/labels/labels.go
  3. 4
      pkg/runtime/limits_windows.go
  4. 4
      pkg/runtime/vmlimits_default.go
  5. 4
      pkg/runtime/vmlimits_openbsd.go
  6. 2
      pkg/textparse/openmetricslex.l
  7. 2
      pkg/textparse/openmetricslex.l.go
  8. 2
      pkg/textparse/openmetricsparse.go
  9. 4
      pkg/textparse/promparse.go
  10. 2
      promql/functions.go
  11. 3
      promql/parser/ast.go
  12. 2
      promql/parser/lex.go
  13. 24
      promql/parser/parse.go
  14. 2
      promql/parser/printer.go
  15. 1
      tsdb/db.go
  16. 2
      tsdb/querier_test.go
  17. 4
      tsdb/tsdbblockutil.go
  18. 1
      tsdb/wal/wal.go
  19. 2
      web/api/v2/api.go
  20. 2
      web/ui/ui.go

2
cmd/prometheus/main.go

@ -334,7 +334,7 @@ func main() {
level.Info(logger).Log("build_context", version.BuildContext()) level.Info(logger).Log("build_context", version.BuildContext())
level.Info(logger).Log("host_details", prom_runtime.Uname()) level.Info(logger).Log("host_details", prom_runtime.Uname())
level.Info(logger).Log("fd_limits", prom_runtime.FdLimits()) level.Info(logger).Log("fd_limits", prom_runtime.FdLimits())
level.Info(logger).Log("vm_limits", prom_runtime.VmLimits()) level.Info(logger).Log("vm_limits", prom_runtime.VMLimits())
var ( var (
localStorage = &readyStorage{} localStorage = &readyStorage{}

6
pkg/labels/labels.go

@ -301,16 +301,14 @@ func Compare(a, b Labels) int {
if a[i].Name != b[i].Name { if a[i].Name != b[i].Name {
if a[i].Name < b[i].Name { if a[i].Name < b[i].Name {
return -1 return -1
} else {
return 1
} }
return 1
} }
if a[i].Value != b[i].Value { if a[i].Value != b[i].Value {
if a[i].Value < b[i].Value { if a[i].Value < b[i].Value {
return -1 return -1
} else {
return 1
} }
return 1
} }
} }
// If all labels so far were in common, the set with fewer labels comes first. // If all labels so far were in common, the set with fewer labels comes first.

4
pkg/runtime/limits_windows.go

@ -20,7 +20,7 @@ func FdLimits() string {
return "N/A" return "N/A"
} }
// VmLimits not supported on Windows // VMLimits not supported on Windows
func VmLimits() string { func VMLimits() string {
return "N/A" return "N/A"
} }

4
pkg/runtime/vmlimits_default.go

@ -20,7 +20,7 @@ import (
"syscall" "syscall"
) )
// VmLimits returns the soft and hard limits for virtual memory. // VMLimits returns the soft and hard limits for virtual memory.
func VmLimits() string { func VMLimits() string {
return getLimits(syscall.RLIMIT_AS, "b") return getLimits(syscall.RLIMIT_AS, "b")
} }

4
pkg/runtime/vmlimits_openbsd.go

@ -19,7 +19,7 @@ import (
"syscall" "syscall"
) )
// VmLimits returns the soft and hard limits for virtual memory. // VMLimits returns the soft and hard limits for virtual memory.
func VmLimits() string { func VMLimits() string {
return getLimits(syscall.RLIMIT_DATA, "b") return getLimits(syscall.RLIMIT_DATA, "b")
} }

2
pkg/textparse/openmetricslex.l

@ -49,7 +49,7 @@ S [ ]
<sComment>HELP{S} l.state = sMeta1; return tHelp <sComment>HELP{S} l.state = sMeta1; return tHelp
<sComment>TYPE{S} l.state = sMeta1; return tType <sComment>TYPE{S} l.state = sMeta1; return tType
<sComment>UNIT{S} l.state = sMeta1; return tUnit <sComment>UNIT{S} l.state = sMeta1; return tUnit
<sComment>"EOF"\n? l.state = sInit; return tEofWord <sComment>"EOF"\n? l.state = sInit; return tEOFWord
<sMeta1>{M}({M}|{D})* l.state = sMeta2; return tMName <sMeta1>{M}({M}|{D})* l.state = sMeta2; return tMName
<sMeta2>{S}{C}*\n l.state = sInit; return tText <sMeta2>{S}{C}*\n l.state = sInit; return tText

2
pkg/textparse/openmetricslex.l.go

@ -635,7 +635,7 @@ yyrule4: // UNIT{S}
yyrule5: // "EOF"\n? yyrule5: // "EOF"\n?
{ {
l.state = sInit l.state = sInit
return tEofWord return tEOFWord
goto yystate0 goto yystate0
} }
yyrule6: // {M}({M}|{D})* yyrule6: // {M}({M}|{D})*

2
pkg/textparse/openmetricsparse.go

@ -233,7 +233,7 @@ func (p *OpenMetricsParser) Next() (Entry, error) {
p.hasExemplarTs = false p.hasExemplarTs = false
switch t := p.nextToken(); t { switch t := p.nextToken(); t {
case tEofWord: case tEOFWord:
if t := p.nextToken(); t != tEOF { if t := p.nextToken(); t != tEOF {
return EntryInvalid, errors.New("unexpected data after # EOF") return EntryInvalid, errors.New("unexpected data after # EOF")
} }

4
pkg/textparse/promparse.go

@ -51,7 +51,7 @@ const (
tHelp tHelp
tType tType
tUnit tUnit
tEofWord tEOFWord
tText tText
tComment tComment
tBlank tBlank
@ -82,7 +82,7 @@ func (t token) String() string {
return "TYPE" return "TYPE"
case tUnit: case tUnit:
return "UNIT" return "UNIT"
case tEofWord: case tEOFWord:
return "EOFWORD" return "EOFWORD"
case tText: case tText:
return "TEXT" return "TEXT"

2
promql/functions.go

@ -870,7 +870,7 @@ func funcYear(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper)
}) })
} }
// Functions is a list of all functions supported by PromQL, including their types. // FunctionCalls is a list of all functions supported by PromQL, including their types.
var FunctionCalls = map[string]FunctionCall{ var FunctionCalls = map[string]FunctionCall{
"abs": funcAbs, "abs": funcAbs,
"absent": funcAbsent, "absent": funcAbsent,

3
promql/parser/ast.go

@ -399,9 +399,8 @@ func (e Expressions) PositionRange() PositionRange {
Start: -1, Start: -1,
End: -1, End: -1,
} }
} else {
return mergeRanges(e[0], e[len(e)-1])
} }
return mergeRanges(e[0], e[len(e)-1])
} }
func (e *MatrixSelector) PositionRange() PositionRange { func (e *MatrixSelector) PositionRange() PositionRange {
return PositionRange{ return PositionRange{

2
promql/parser/lex.go

@ -122,7 +122,7 @@ var key = map[string]ItemType{
"bool": BOOL, "bool": BOOL,
} }
// These are the default string representations for common Items. It does not // ItemTypeStr is the default string representations for common Items. It does not
// imply that those are the only character sequences that can be lexed to such an Item. // imply that those are the only character sequences that can be lexed to such an Item.
var ItemTypeStr = map[ItemType]string{ var ItemTypeStr = map[ItemType]string{
LEFT_PAREN: "(", LEFT_PAREN: "(",

24
promql/parser/parse.go

@ -94,12 +94,11 @@ type ParseErrors []ParseErr
func (errs ParseErrors) Error() string { func (errs ParseErrors) Error() string {
if len(errs) != 0 { if len(errs) != 0 {
return errs[0].Error() return errs[0].Error()
} else {
// Should never happen
// Panicking while printing an error seems like a bad idea, so the
// situation is explained in the error message instead.
return "error contains no error message"
} }
// Should never happen
// Panicking while printing an error seems like a bad idea, so the
// situation is explained in the error message instead.
return "error contains no error message"
} }
// ParseExpr returns the expression parsed from the input. // ParseExpr returns the expression parsed from the input.
@ -295,14 +294,13 @@ func (p *parser) Lex(lval *yySymType) int {
if p.injecting { if p.injecting {
p.injecting = false p.injecting = false
return int(p.inject) return int(p.inject)
} else { }
// Skip comments. // Skip comments.
for { for {
p.lex.NextItem(&lval.item) p.lex.NextItem(&lval.item)
typ = lval.item.Typ typ = lval.item.Typ
if typ != COMMENT { if typ != COMMENT {
break break
}
} }
} }

2
promql/parser/printer.go

@ -113,7 +113,7 @@ func (node *Call) String() string {
func (node *MatrixSelector) String() string { func (node *MatrixSelector) String() string {
// Copy the Vector selector before changing the offset // Copy the Vector selector before changing the offset
var vecSelector VectorSelector = *node.VectorSelector.(*VectorSelector) vecSelector := *node.VectorSelector.(*VectorSelector)
offset := "" offset := ""
if vecSelector.Offset != time.Duration(0) { if vecSelector.Offset != time.Duration(0) {
offset = fmt.Sprintf(" offset %s", model.Duration(vecSelector.Offset)) offset = fmt.Sprintf(" offset %s", model.Duration(vecSelector.Offset))

1
tsdb/db.go

@ -39,6 +39,7 @@ import (
"github.com/prometheus/prometheus/tsdb/chunkenc" "github.com/prometheus/prometheus/tsdb/chunkenc"
tsdb_errors "github.com/prometheus/prometheus/tsdb/errors" tsdb_errors "github.com/prometheus/prometheus/tsdb/errors"
"github.com/prometheus/prometheus/tsdb/fileutil" "github.com/prometheus/prometheus/tsdb/fileutil"
// Load the package into main to make sure minium Go version is met.
_ "github.com/prometheus/prometheus/tsdb/goversion" _ "github.com/prometheus/prometheus/tsdb/goversion"
"github.com/prometheus/prometheus/tsdb/wal" "github.com/prometheus/prometheus/tsdb/wal"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"

2
tsdb/querier_test.go

@ -234,7 +234,7 @@ func createIdxChkReaders(t *testing.T, tc []seriesSamples) (IndexReader, ChunkRe
app.Append(smpl.t, smpl.v) app.Append(smpl.t, smpl.v)
} }
chkReader[chunkRef] = chunk chkReader[chunkRef] = chunk
chunkRef += 1 chunkRef++
} }
ls := labels.FromMap(s.lset) ls := labels.FromMap(s.lset)

4
tsdb/tsdbblockutil.go

@ -23,7 +23,7 @@ import (
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"
) )
var InvalidTimesError = fmt.Errorf("max time is lesser than min time") var ErrInvalidTimes = fmt.Errorf("max time is lesser than min time")
type MetricSample struct { type MetricSample struct {
TimestampMs int64 TimestampMs int64
@ -58,7 +58,7 @@ func CreateBlock(samples []*MetricSample, dir string, mint, maxt int64, logger l
chunkRange = DefaultBlockDuration chunkRange = DefaultBlockDuration
} }
if chunkRange < 0 { if chunkRange < 0 {
return "", InvalidTimesError return "", ErrInvalidTimes
} }
head, err := CreateHead(samples, chunkRange, logger) head, err := CreateHead(samples, chunkRange, logger)
if err != nil { if err != nil {

1
tsdb/wal/wal.go

@ -837,6 +837,7 @@ type segmentBufReader struct {
off int // Offset of read data into current segment. off int // Offset of read data into current segment.
} }
// nolint:golint // TODO: Consider exporting segmentBufReader
func NewSegmentBufReader(segs ...*Segment) *segmentBufReader { func NewSegmentBufReader(segs ...*Segment) *segmentBufReader {
return &segmentBufReader{ return &segmentBufReader{
buf: bufio.NewReaderSize(segs[0], 16*pageSize), buf: bufio.NewReaderSize(segs[0], 16*pageSize),

2
web/api/v2/api.go

@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package api_v2 package apiv2
import ( import (
"context" "context"

2
web/ui/ui.go

@ -26,7 +26,7 @@ import (
) )
// Assets contains the project's assets. // Assets contains the project's assets.
var Assets http.FileSystem = func() http.FileSystem { var Assets = func() http.FileSystem {
wd, err := os.Getwd() wd, err := os.Getwd()
if err != nil { if err != nil {
panic(err) panic(err)

Loading…
Cancel
Save