You've already forked postgres_exporter
mirror of
https://github.com/prometheus-community/postgres_exporter.git
synced 2025-08-08 04:42:07 +03:00
Add cross-compilation Makefile targets and tar-based releases.
Revamp the build system to be more inline with other Prometheus exporters. Notably add Darwin and Windows build targets, and add support for releases using tar files.
This commit is contained in:
62
tools/vendor/github.com/alecthomas/gometalinter/directives.go
generated
vendored
62
tools/vendor/github.com/alecthomas/gometalinter/directives.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
@@ -14,6 +15,7 @@ type ignoredRange struct {
|
||||
col int
|
||||
start, end int
|
||||
linters []string
|
||||
matched bool
|
||||
}
|
||||
|
||||
func (i *ignoredRange) matches(issue *Issue) bool {
|
||||
@@ -35,6 +37,14 @@ func (i *ignoredRange) near(col, start int) bool {
|
||||
return col == i.col && i.end == start-1
|
||||
}
|
||||
|
||||
func (i *ignoredRange) String() string {
|
||||
linters := strings.Join(i.linters, ",")
|
||||
if len(i.linters) == 0 {
|
||||
linters = "all"
|
||||
}
|
||||
return fmt.Sprintf("%s:%d-%d", linters, i.start, i.end)
|
||||
}
|
||||
|
||||
type ignoredRanges []*ignoredRange
|
||||
|
||||
func (ir ignoredRanges) Len() int { return len(ir) }
|
||||
@@ -66,12 +76,43 @@ func (d *directiveParser) IsIgnored(issue *Issue) bool {
|
||||
d.lock.Unlock()
|
||||
for _, r := range ranges {
|
||||
if r.matches(issue) {
|
||||
debug("nolint: matched %s to issue %s", r, issue)
|
||||
r.matched = true
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Unmatched returns all the ranges which were never used to ignore an issue
|
||||
func (d *directiveParser) Unmatched() map[string]ignoredRanges {
|
||||
unmatched := map[string]ignoredRanges{}
|
||||
for path, ranges := range d.files {
|
||||
for _, ignore := range ranges {
|
||||
if !ignore.matched {
|
||||
unmatched[path] = append(unmatched[path], ignore)
|
||||
}
|
||||
}
|
||||
}
|
||||
return unmatched
|
||||
}
|
||||
|
||||
// LoadFiles from a list of directories
|
||||
func (d *directiveParser) LoadFiles(paths []string) error {
|
||||
d.lock.Lock()
|
||||
defer d.lock.Unlock()
|
||||
filenames, err := pathsToFileGlobs(paths)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, filename := range filenames {
|
||||
ranges := d.parseFile(filename)
|
||||
sort.Sort(ranges)
|
||||
d.files[filename] = ranges
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Takes a set of ignoredRanges, determines if they immediately precede a statement
|
||||
// construct, and expands the range to include that construct. Why? So you can
|
||||
// precede a function or struct with //nolint
|
||||
@@ -150,7 +191,28 @@ func filterIssuesViaDirectives(directives *directiveParser, issues chan *Issue)
|
||||
out <- issue
|
||||
}
|
||||
}
|
||||
|
||||
if config.WarnUnmatchedDirective {
|
||||
for _, issue := range warnOnUnusedDirective(directives) {
|
||||
out <- issue
|
||||
}
|
||||
}
|
||||
close(out)
|
||||
}()
|
||||
return out
|
||||
}
|
||||
|
||||
func warnOnUnusedDirective(directives *directiveParser) []*Issue {
|
||||
out := []*Issue{}
|
||||
for path, ranges := range directives.Unmatched() {
|
||||
for _, ignore := range ranges {
|
||||
issue, _ := NewIssue("nolint", config.formatTemplate)
|
||||
issue.Path = path
|
||||
issue.Line = ignore.start
|
||||
issue.Col = ignore.col
|
||||
issue.Message = "nolint directive did not match any issue"
|
||||
out = append(out, issue)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
Reference in New Issue
Block a user