Skip to content

Commit

Permalink
Revive fixes - part 4: (influxdata#8981)
Browse files Browse the repository at this point in the history
empty-lines

Co-authored-by: Pawel Zak <Pawel Zak>
  • Loading branch information
zak-pawel authored Mar 12, 2021
1 parent 9ddd189 commit 38c61c0
Show file tree
Hide file tree
Showing 194 changed files with 28 additions and 457 deletions.
1 change: 0 additions & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ func (a *Agent) testStartInputs(
if err != nil {
log.Printf("E! [agent] Starting input %s: %v", input.LogName(), err)
}

}

unit.inputs = append(unit.inputs, input)
Expand Down
1 change: 0 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,6 @@ func loadConfig(config string) ([]byte, error) {
// If it isn't a https scheme, try it as a file.
}
return ioutil.ReadFile(config)

}

func fetchConfig(u *url.URL) ([]byte, error) {
Expand Down
1 change: 0 additions & 1 deletion internal/content_coding.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func (r *GzipReader) Read(b []byte) (int, error) {
return n, nil
}
return n, err

}

// NewContentEncoder returns a ContentEncoder for the encoding type.
Expand Down
1 change: 0 additions & 1 deletion internal/globpath/globpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var (
)

func TestCompileAndMatch(t *testing.T) {

type test struct {
path string
matches int
Expand Down
2 changes: 0 additions & 2 deletions internal/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func (h *basicAuthHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
if !ok ||
subtle.ConstantTimeCompare([]byte(reqUsername), []byte(h.username)) != 1 ||
subtle.ConstantTimeCompare([]byte(reqPassword), []byte(h.password)) != 1 {

rw.Header().Set("WWW-Authenticate", "Basic realm=\""+h.realm+"\"")
h.onError(rw)
http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
Expand Down Expand Up @@ -73,7 +72,6 @@ func (h *genericAuthHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request
// Scheme checking
authorization := req.Header.Get("Authorization")
if subtle.ConstantTimeCompare([]byte(authorization), []byte(h.credentials)) != 1 {

h.onError(rw)
http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
Expand Down
1 change: 0 additions & 1 deletion metric/tracking.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func newTrackingMetricGroup(group []telegraf.Metric, fn NotifyFunc) ([]telegraf.
d: d,
}
group[i] = dm

}
if finalizer != nil {
runtime.SetFinalizer(d, finalizer)
Expand Down
3 changes: 0 additions & 3 deletions models/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ func TestFilter_FilterTagsMatches(t *testing.T) {
// both parameters were defined
// see: https://github.com/influxdata/telegraf/issues/2860
func TestFilter_FilterNamePassAndDrop(t *testing.T) {

inputData := []string{"name1", "name2", "name3", "name4"}
expectedResult := []bool{false, true, false, false}

Expand All @@ -422,7 +421,6 @@ func TestFilter_FilterNamePassAndDrop(t *testing.T) {
// both parameters were defined
// see: https://github.com/influxdata/telegraf/issues/2860
func TestFilter_FilterFieldPassAndDrop(t *testing.T) {

inputData := []string{"field1", "field2", "field3", "field4"}
expectedResult := []bool{false, true, false, false}

Expand Down Expand Up @@ -479,7 +477,6 @@ func TestFilter_FilterTagsPassAndDrop(t *testing.T) {
for i, tag := range inputData {
require.Equal(t, f.shouldTagsPass(tag), expectedResult[i])
}

}

func BenchmarkFilter(b *testing.B) {
Expand Down
1 change: 0 additions & 1 deletion models/running_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func (r *RunningOutput) Init() error {
if err != nil {
return err
}

}
return nil
}
Expand Down
1 change: 0 additions & 1 deletion plugins/aggregators/basicstats/basicstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ func (b *BasicStats) Push(acc telegraf.Accumulator) {
for _, aggregate := range b.cache {
fields := map[string]interface{}{}
for k, v := range aggregate.fields {

if b.statsConfig.count {
fields[k+"_count"] = v.count
}
Expand Down
17 changes: 0 additions & 17 deletions plugins/aggregators/basicstats/basicstats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ func TestBasicStatsDifferentPeriods(t *testing.T) {

// Test only aggregating count
func TestBasicStatsWithOnlyCount(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"count"}
aggregator.Log = testutil.Logger{}
Expand Down Expand Up @@ -213,7 +212,6 @@ func TestBasicStatsWithOnlyCount(t *testing.T) {

// Test only aggregating minimum
func TestBasicStatsWithOnlyMin(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"min"}
aggregator.Log = testutil.Logger{}
Expand Down Expand Up @@ -242,7 +240,6 @@ func TestBasicStatsWithOnlyMin(t *testing.T) {

// Test only aggregating maximum
func TestBasicStatsWithOnlyMax(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"max"}
aggregator.Log = testutil.Logger{}
Expand Down Expand Up @@ -271,7 +268,6 @@ func TestBasicStatsWithOnlyMax(t *testing.T) {

// Test only aggregating mean
func TestBasicStatsWithOnlyMean(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"mean"}
aggregator.Log = testutil.Logger{}
Expand Down Expand Up @@ -300,7 +296,6 @@ func TestBasicStatsWithOnlyMean(t *testing.T) {

// Test only aggregating sum
func TestBasicStatsWithOnlySum(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"sum"}
aggregator.Log = testutil.Logger{}
Expand Down Expand Up @@ -331,7 +326,6 @@ func TestBasicStatsWithOnlySum(t *testing.T) {
// implementations of sum were calculated from mean and count, which
// e.g. summed "1, 1, 5, 1" as "7.999999..." instead of 8.
func TestBasicStatsWithOnlySumFloatingPointErrata(t *testing.T) {

var sum1, _ = metric.New("m1",
map[string]string{},
map[string]interface{}{
Expand Down Expand Up @@ -383,7 +377,6 @@ func TestBasicStatsWithOnlySumFloatingPointErrata(t *testing.T) {

// Test only aggregating variance
func TestBasicStatsWithOnlyVariance(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"s2"}
aggregator.Log = testutil.Logger{}
Expand All @@ -410,7 +403,6 @@ func TestBasicStatsWithOnlyVariance(t *testing.T) {

// Test only aggregating standard deviation
func TestBasicStatsWithOnlyStandardDeviation(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"stdev"}
aggregator.Log = testutil.Logger{}
Expand All @@ -437,7 +429,6 @@ func TestBasicStatsWithOnlyStandardDeviation(t *testing.T) {

// Test only aggregating minimum and maximum
func TestBasicStatsWithMinAndMax(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"min", "max"}
aggregator.Log = testutil.Logger{}
Expand Down Expand Up @@ -473,7 +464,6 @@ func TestBasicStatsWithMinAndMax(t *testing.T) {

// Test only aggregating diff
func TestBasicStatsWithDiff(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"diff"}
aggregator.Log = testutil.Logger{}
Expand All @@ -499,7 +489,6 @@ func TestBasicStatsWithDiff(t *testing.T) {
}

func TestBasicStatsWithRate(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"rate"}
aggregator.Log = testutil.Logger{}
Expand All @@ -524,7 +513,6 @@ func TestBasicStatsWithRate(t *testing.T) {
}

func TestBasicStatsWithNonNegativeRate(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"non_negative_rate"}
aggregator.Log = testutil.Logger{}
Expand All @@ -548,7 +536,6 @@ func TestBasicStatsWithNonNegativeRate(t *testing.T) {
acc.AssertContainsTaggedFields(t, "m1", expectedFields, expectedTags)
}
func TestBasicStatsWithInterval(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"interval"}
aggregator.Log = testutil.Logger{}
Expand All @@ -575,7 +562,6 @@ func TestBasicStatsWithInterval(t *testing.T) {

// Test only aggregating non_negative_diff
func TestBasicStatsWithNonNegativeDiff(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"non_negative_diff"}
aggregator.Log = testutil.Logger{}
Expand Down Expand Up @@ -666,7 +652,6 @@ func TestBasicStatsWithAllStats(t *testing.T) {

// Test that if an empty array is passed, no points are pushed
func TestBasicStatsWithNoStats(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{}
aggregator.Log = testutil.Logger{}
Expand All @@ -683,7 +668,6 @@ func TestBasicStatsWithNoStats(t *testing.T) {

// Test that if an unknown stat is configured, it doesn't explode
func TestBasicStatsWithUnknownStat(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Stats = []string{"crazy"}
aggregator.Log = testutil.Logger{}
Expand All @@ -703,7 +687,6 @@ func TestBasicStatsWithUnknownStat(t *testing.T) {
// otherwise user's working systems will suddenly (and surprisingly) start
// capturing sum without their input.
func TestBasicStatsWithDefaultStats(t *testing.T) {

aggregator := NewBasicStats()
aggregator.Log = testutil.Logger{}
aggregator.getConfiguredStats()
Expand Down
1 change: 0 additions & 1 deletion plugins/aggregators/derivative/derivative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func TestTwoFullEventsWithoutParameter(t *testing.T) {
"value_rate": float64(5),
},
)

}

func TestTwoFullEventsInSeperatePushes(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion plugins/aggregators/histogram/histogram_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func TestHistogramWithAllFieldsNonCumulative(t *testing.T) {
// TestHistogramWithTwoPeriodsAndAllFields tests two metrics getting added with a push/reset in between (simulates
// getting added in different periods) for all fields
func TestHistogramWithTwoPeriodsAndAllFields(t *testing.T) {

var cfg []config
cfg = append(cfg, config{Metric: "first_metric_name", Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
histogram := NewTestHistogram(cfg, false, true)
Expand Down
1 change: 0 additions & 1 deletion plugins/common/kafka/sasl.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,4 @@ func gssapiAuthType(authType string) int {
default:
return 0
}

}
2 changes: 0 additions & 2 deletions plugins/common/shim/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ func LoadConfig(filePath *string) (loaded loadedConfig, err error) {
var data string
conf := config{}
if filePath != nil && *filePath != "" {

b, err := ioutil.ReadFile(*filePath)
if err != nil {
return loadedConfig{}, err
}

data = expandEnvVars(b)

} else {
conf, err = DefaultImportedPlugins()
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions plugins/inputs/activemq/activemq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

func TestGatherQueuesMetrics(t *testing.T) {

s := `<queues>
<queue name="sandra">
<stats size="0" consumerCount="0" enqueueCount="0" dequeueCount="0"/>
Expand Down Expand Up @@ -57,7 +56,6 @@ func TestGatherQueuesMetrics(t *testing.T) {
}

func TestGatherTopicsMetrics(t *testing.T) {

s := `<topics>
<topic name="ActiveMQ.Advisory.MasterBroker ">
<stats size="0" consumerCount="0" enqueueCount="1" dequeueCount="0"/>
Expand Down Expand Up @@ -104,7 +102,6 @@ func TestGatherTopicsMetrics(t *testing.T) {
}

func TestGatherSubscribersMetrics(t *testing.T) {

s := `<subscribers>
<subscriber clientId="AAA" subscriptionName="AAA" connectionId="NOTSET" destinationName="AAA" selector="AA" active="no">
<stats pendingQueueSize="0" dispatchedQueueSize="0" dispatchedCounter="0" enqueueCounter="0" dequeueCounter="0"/>
Expand Down
7 changes: 0 additions & 7 deletions plugins/inputs/aerospike/aerospike.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ func (a *Aerospike) parseNodeInfo(stats map[string]string, hostPort string, node
for k, v := range stats {
key := strings.Replace(k, "-", "_", -1)
fields[key] = parseAerospikeValue(key, v)

}
acc.AddFields("aerospike_node", fields, tags, time.Now())

Expand Down Expand Up @@ -279,7 +278,6 @@ func (a *Aerospike) getNamespaceInfo(namespace string, n *as.Node) (map[string]s
return stats, err
}
func (a *Aerospike) parseNamespaceInfo(stats map[string]string, hostPort string, namespace string, nodeName string, acc telegraf.Accumulator) {

nTags := map[string]string{
"aerospike_host": hostPort,
"node_name": nodeName,
Expand Down Expand Up @@ -348,7 +346,6 @@ func (a *Aerospike) getSetInfo(namespaceSet string, n *as.Node) (map[string]stri
}

func (a *Aerospike) parseSetInfo(stats map[string]string, hostPort string, namespaceSet string, nodeName string, acc telegraf.Accumulator) {

stat := strings.Split(
strings.TrimSuffix(
stats[fmt.Sprintf("sets/%s", namespaceSet)], ";"), ":")
Expand Down Expand Up @@ -383,7 +380,6 @@ func (a *Aerospike) getTTLHistogram(hostPort string, namespace string, set strin
}

func (a *Aerospike) getObjectSizeLinearHistogram(hostPort string, namespace string, set string, n *as.Node, acc telegraf.Accumulator) error {

stats, err := a.getHistogram(namespace, set, "object-size-linear", n)
if err != nil {
return err
Expand All @@ -406,11 +402,9 @@ func (a *Aerospike) getHistogram(namespace string, set string, histogramType str
return nil, err
}
return stats, nil

}

func (a *Aerospike) parseHistogram(stats map[string]string, hostPort string, namespace string, set string, histogramType string, nodeName string, acc telegraf.Accumulator) {

nTags := map[string]string{
"aerospike_host": hostPort,
"node_name": nodeName,
Expand Down Expand Up @@ -463,7 +457,6 @@ func (a *Aerospike) parseHistogram(stats map[string]string, hostPort string, nam
nFields[strconv.Itoa(bucketName)] = bucketSum
}
}

}
}
}
Expand Down
Loading

0 comments on commit 38c61c0

Please sign in to comment.