all: gometalinter (#843)

* kubernetes/reverse: remove deadcode
* deadcode in errors and kubernetes removed
* unnecessary conversion
* constants
* proxy: time.Since()
* simplications
* static check
* Disable test/external_test
This commit is contained in:
Miek Gieben
2017-08-06 05:54:24 -07:00
committed by GitHub
parent 964f04f443
commit bcb2eb1ecc
25 changed files with 105 additions and 150 deletions

View File

@@ -69,7 +69,7 @@ type (
func Scrape(t *testing.T, url string) []*MetricFamily {
mfChan := make(chan *dto.MetricFamily, 1024)
go fetchMetricFamilies(t, url, mfChan)
go fetchMetricFamilies(url, mfChan)
result := []*MetricFamily{}
for mf := range mfChan {
@@ -177,20 +177,20 @@ func makeBuckets(m *dto.Metric) map[string]string {
return result
}
func fetchMetricFamilies(t *testing.T, url string, ch chan<- *dto.MetricFamily) {
func fetchMetricFamilies(url string, ch chan<- *dto.MetricFamily) {
defer close(ch)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
t.Fatalf("creating GET request for URL %q failed: %s", url, err)
return
}
req.Header.Add("Accept", acceptHeader)
resp, err := http.DefaultClient.Do(req)
if err != nil {
t.Fatalf("executing GET request for URL %q failed: %s", url, err)
return
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
t.Fatalf("GET request for URL %q returned HTTP status %s", url, resp.Status)
return
}
mediatype, params, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
@@ -203,7 +203,7 @@ func fetchMetricFamilies(t *testing.T, url string, ch chan<- *dto.MetricFamily)
if err == io.EOF {
break
}
t.Fatalf("reading metric family protocol buffer failed: %s", err)
return
}
ch <- mf
}
@@ -214,7 +214,7 @@ func fetchMetricFamilies(t *testing.T, url string, ch chan<- *dto.MetricFamily)
var parser expfmt.TextParser
metricFamilies, err := parser.TextToMetricFamilies(resp.Body)
if err != nil {
t.Fatal("reading text format failed:", err)
return
}
for _, mf := range metricFamilies {
ch <- mf