ci(lint): enable errorlint linter on model

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
pull/12907/head
Matthieu MOREL 1 year ago
parent a38179c4e1
commit 0a513f827d

@ -35,9 +35,6 @@ issues:
- path: discovery/ - path: discovery/
linters: linters:
- errorlint - errorlint
- path: model/
linters:
- errorlint
- path: scrape/ - path: scrape/
linters: linters:
- errorlint - errorlint

@ -338,7 +338,7 @@ func (p *OpenMetricsParser) Next() (Entry, error) {
var ts float64 var ts float64
// A float is enough to hold what we need for millisecond resolution. // A float is enough to hold what we need for millisecond resolution.
if ts, err = parseFloat(yoloString(p.l.buf()[1:])); err != nil { if ts, err = parseFloat(yoloString(p.l.buf()[1:])); err != nil {
return EntryInvalid, fmt.Errorf("%v while parsing: %q", err, p.l.b[p.start:p.l.i]) return EntryInvalid, fmt.Errorf("%w while parsing: %q", err, p.l.b[p.start:p.l.i])
} }
if math.IsNaN(ts) || math.IsInf(ts, 0) { if math.IsNaN(ts) || math.IsInf(ts, 0) {
return EntryInvalid, fmt.Errorf("invalid timestamp %f", ts) return EntryInvalid, fmt.Errorf("invalid timestamp %f", ts)
@ -391,7 +391,7 @@ func (p *OpenMetricsParser) parseComment() error {
var ts float64 var ts float64
// A float is enough to hold what we need for millisecond resolution. // A float is enough to hold what we need for millisecond resolution.
if ts, err = parseFloat(yoloString(p.l.buf()[1:])); err != nil { if ts, err = parseFloat(yoloString(p.l.buf()[1:])); err != nil {
return fmt.Errorf("%v while parsing: %q", err, p.l.b[p.start:p.l.i]) return fmt.Errorf("%w while parsing: %q", err, p.l.b[p.start:p.l.i])
} }
if math.IsNaN(ts) || math.IsInf(ts, 0) { if math.IsNaN(ts) || math.IsInf(ts, 0) {
return fmt.Errorf("invalid exemplar timestamp %f", ts) return fmt.Errorf("invalid exemplar timestamp %f", ts)
@ -461,7 +461,7 @@ func (p *OpenMetricsParser) getFloatValue(t token, after string) (float64, error
} }
val, err := parseFloat(yoloString(p.l.buf()[1:])) val, err := parseFloat(yoloString(p.l.buf()[1:]))
if err != nil { if err != nil {
return 0, fmt.Errorf("%v while parsing: %q", err, p.l.b[p.start:p.l.i]) return 0, fmt.Errorf("%w while parsing: %q", err, p.l.b[p.start:p.l.i])
} }
// Ensure canonical NaN value. // Ensure canonical NaN value.
if math.IsNaN(p.exemplarVal) { if math.IsNaN(p.exemplarVal) {

@ -348,7 +348,7 @@ func (p *PromParser) Next() (Entry, error) {
return EntryInvalid, p.parseError("expected value after metric", t2) return EntryInvalid, p.parseError("expected value after metric", t2)
} }
if p.val, err = parseFloat(yoloString(p.l.buf())); err != nil { if p.val, err = parseFloat(yoloString(p.l.buf())); err != nil {
return EntryInvalid, fmt.Errorf("%v while parsing: %q", err, p.l.b[p.start:p.l.i]) return EntryInvalid, fmt.Errorf("%w while parsing: %q", err, p.l.b[p.start:p.l.i])
} }
// Ensure canonical NaN value. // Ensure canonical NaN value.
if math.IsNaN(p.val) { if math.IsNaN(p.val) {
@ -361,7 +361,7 @@ func (p *PromParser) Next() (Entry, error) {
case tTimestamp: case tTimestamp:
p.hasTS = true p.hasTS = true
if p.ts, err = strconv.ParseInt(yoloString(p.l.buf()), 10, 64); err != nil { if p.ts, err = strconv.ParseInt(yoloString(p.l.buf()), 10, 64); err != nil {
return EntryInvalid, fmt.Errorf("%v while parsing: %q", err, p.l.b[p.start:p.l.i]) return EntryInvalid, fmt.Errorf("%w while parsing: %q", err, p.l.b[p.start:p.l.i])
} }
if t2 := p.nextToken(); t2 != tLinebreak { if t2 := p.nextToken(); t2 != tLinebreak {
return EntryInvalid, p.parseError("expected next entry after timestamp", t2) return EntryInvalid, p.parseError("expected next entry after timestamp", t2)

Loading…
Cancel
Save