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. 6
      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("host_details", prom_runtime.Uname())
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 (
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 {
return -1
} else {
return 1
}
return 1
}
if a[i].Value != b[i].Value {
if a[i].Value < b[i].Value {
return -1
} else {
return 1
}
return 1
}
}
// 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"
}
// VmLimits not supported on Windows
func VmLimits() string {
// VMLimits not supported on Windows
func VMLimits() string {
return "N/A"
}

4
pkg/runtime/vmlimits_default.go

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

4
pkg/runtime/vmlimits_openbsd.go

@ -19,7 +19,7 @@ import (
"syscall"
)
// VmLimits returns the soft and hard limits for virtual memory.
func VmLimits() string {
// VMLimits returns the soft and hard limits for virtual memory.
func VMLimits() string {
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>TYPE{S} l.state = sMeta1; return tType
<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
<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?
{
l.state = sInit
return tEofWord
return tEOFWord
goto yystate0
}
yyrule6: // {M}({M}|{D})*

2
pkg/textparse/openmetricsparse.go

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

4
pkg/textparse/promparse.go

@ -51,7 +51,7 @@ const (
tHelp
tType
tUnit
tEofWord
tEOFWord
tText
tComment
tBlank
@ -82,7 +82,7 @@ func (t token) String() string {
return "TYPE"
case tUnit:
return "UNIT"
case tEofWord:
case tEOFWord:
return "EOFWORD"
case tText:
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{
"abs": funcAbs,
"absent": funcAbsent,

3
promql/parser/ast.go

@ -399,9 +399,8 @@ func (e Expressions) PositionRange() PositionRange {
Start: -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 {
return PositionRange{

2
promql/parser/lex.go

@ -122,7 +122,7 @@ var key = map[string]ItemType{
"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.
var ItemTypeStr = map[ItemType]string{
LEFT_PAREN: "(",

6
promql/parser/parse.go

@ -94,13 +94,12 @@ type ParseErrors []ParseErr
func (errs ParseErrors) Error() string {
if len(errs) != 0 {
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"
}
}
// ParseExpr returns the expression parsed from the input.
func ParseExpr(input string) (expr Expr, err error) {
@ -295,7 +294,7 @@ func (p *parser) Lex(lval *yySymType) int {
if p.injecting {
p.injecting = false
return int(p.inject)
} else {
}
// Skip comments.
for {
p.lex.NextItem(&lval.item)
@ -304,7 +303,6 @@ func (p *parser) Lex(lval *yySymType) int {
break
}
}
}
switch typ {
case ERROR:

2
promql/parser/printer.go

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

1
tsdb/db.go

@ -39,6 +39,7 @@ import (
"github.com/prometheus/prometheus/tsdb/chunkenc"
tsdb_errors "github.com/prometheus/prometheus/tsdb/errors"
"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/wal"
"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)
}
chkReader[chunkRef] = chunk
chunkRef += 1
chunkRef++
}
ls := labels.FromMap(s.lset)

4
tsdb/tsdbblockutil.go

@ -23,7 +23,7 @@ import (
"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 {
TimestampMs int64
@ -58,7 +58,7 @@ func CreateBlock(samples []*MetricSample, dir string, mint, maxt int64, logger l
chunkRange = DefaultBlockDuration
}
if chunkRange < 0 {
return "", InvalidTimesError
return "", ErrInvalidTimes
}
head, err := CreateHead(samples, chunkRange, logger)
if err != nil {

1
tsdb/wal/wal.go

@ -837,6 +837,7 @@ type segmentBufReader struct {
off int // Offset of read data into current segment.
}
// nolint:golint // TODO: Consider exporting segmentBufReader
func NewSegmentBufReader(segs ...*Segment) *segmentBufReader {
return &segmentBufReader{
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
// limitations under the License.
package api_v2
package apiv2
import (
"context"

2
web/ui/ui.go

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

Loading…
Cancel
Save