Skip to content

Commit 8a6907a

Browse files
authored
Revive fixes - part 3 (influxdata#8872)
* * Revive fixes regarding following set of rules: [rule.var-naming]
1 parent 4584d69 commit 8a6907a

File tree

154 files changed

+1361
-1340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+1361
-1340
lines changed

.golangci.yml

+24
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,38 @@ linters-settings:
3131
- name: redefines-builtin-id
3232

3333
run:
34+
# which dirs to skip: issues from them won't be reported;
35+
# can use regexp here: generated.*, regexp is applied on full path;
36+
# default value is empty list, but default dirs are skipped independently
37+
# from this option's value (see skip-dirs-use-default).
38+
# "/" will be replaced by current OS file path separator to properly work
39+
# on Windows.
3440
skip-dirs:
3541
- scripts
3642
- docs
3743
- etc
44+
45+
# which files to skip: they will be analyzed, but issues from them
46+
# won't be reported. Default value is empty list, but there is
47+
# no need to include all autogenerated files, we confidently recognize
48+
# autogenerated files. If it's not please let us know.
49+
# "/" will be replaced by current OS file path separator to properly work
50+
# on Windows.
3851
skip-files:
3952
- plugins/parsers/influx/machine.go*
4053

4154
issues:
55+
# List of regexps of issue texts to exclude, empty list by default.
56+
# But independently from this option we use default exclude patterns,
57+
# it can be disabled by `exclude-use-default: false`. To list all
58+
# excluded by default patterns execute `golangci-lint run --help`
4259
exclude:
4360
- don't use an underscore in package name
4461
- exported.*should have comment.*or be unexported
62+
- comment on exported.*should be of the form
63+
64+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
65+
max-issues-per-linter: 0
66+
67+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
68+
max-same-issues: 0

plugins/aggregators/basicstats/basicstats.go

+26-26
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ type BasicStats struct {
1717
}
1818

1919
type configuredStats struct {
20-
count bool
21-
min bool
22-
max bool
23-
mean bool
24-
variance bool
25-
stdev bool
26-
sum bool
27-
diff bool
28-
non_negative_diff bool
29-
rate bool
30-
non_negative_rate bool
31-
interval bool
20+
count bool
21+
min bool
22+
max bool
23+
mean bool
24+
variance bool
25+
stdev bool
26+
sum bool
27+
diff bool
28+
nonNegativeDiff bool
29+
rate bool
30+
nonNegativeRate bool
31+
interval bool
3232
}
3333

3434
func NewBasicStats() *BasicStats {
@@ -197,13 +197,13 @@ func (b *BasicStats) Push(acc telegraf.Accumulator) {
197197
if b.statsConfig.diff {
198198
fields[k+"_diff"] = v.diff
199199
}
200-
if b.statsConfig.non_negative_diff && v.diff >= 0 {
200+
if b.statsConfig.nonNegativeDiff && v.diff >= 0 {
201201
fields[k+"_non_negative_diff"] = v.diff
202202
}
203203
if b.statsConfig.rate {
204204
fields[k+"_rate"] = v.rate
205205
}
206-
if b.statsConfig.non_negative_rate && v.diff >= 0 {
206+
if b.statsConfig.nonNegativeRate && v.diff >= 0 {
207207
fields[k+"_non_negative_rate"] = v.rate
208208
}
209209
if b.statsConfig.interval {
@@ -242,11 +242,11 @@ func (b *BasicStats) parseStats() *configuredStats {
242242
case "diff":
243243
parsed.diff = true
244244
case "non_negative_diff":
245-
parsed.non_negative_diff = true
245+
parsed.nonNegativeDiff = true
246246
case "rate":
247247
parsed.rate = true
248248
case "non_negative_rate":
249-
parsed.non_negative_rate = true
249+
parsed.nonNegativeRate = true
250250
case "interval":
251251
parsed.interval = true
252252
default:
@@ -260,16 +260,16 @@ func (b *BasicStats) parseStats() *configuredStats {
260260
func (b *BasicStats) getConfiguredStats() {
261261
if b.Stats == nil {
262262
b.statsConfig = &configuredStats{
263-
count: true,
264-
min: true,
265-
max: true,
266-
mean: true,
267-
variance: true,
268-
stdev: true,
269-
sum: false,
270-
non_negative_diff: false,
271-
rate: false,
272-
non_negative_rate: false,
263+
count: true,
264+
min: true,
265+
max: true,
266+
mean: true,
267+
variance: true,
268+
stdev: true,
269+
sum: false,
270+
nonNegativeDiff: false,
271+
rate: false,
272+
nonNegativeRate: false,
273273
}
274274
} else {
275275
b.statsConfig = b.parseStats()

plugins/inputs/activemq/activemq.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ type Subscribers struct {
4949

5050
type Subscriber struct {
5151
XMLName xml.Name `xml:"subscriber"`
52-
ClientId string `xml:"clientId,attr"`
52+
ClientID string `xml:"clientId,attr"`
5353
SubscriptionName string `xml:"subscriptionName,attr"`
54-
ConnectionId string `xml:"connectionId,attr"`
54+
ConnectionID string `xml:"connectionId,attr"`
5555
DestinationName string `xml:"destinationName,attr"`
5656
Selector string `xml:"selector,attr"`
5757
Active string `xml:"active,attr"`
@@ -117,7 +117,7 @@ func (a *ActiveMQ) SampleConfig() string {
117117
return sampleConfig
118118
}
119119

120-
func (a *ActiveMQ) createHttpClient() (*http.Client, error) {
120+
func (a *ActiveMQ) createHTTPClient() (*http.Client, error) {
121121
tlsCfg, err := a.ClientConfig.TLSConfig()
122122
if err != nil {
123123
return nil, err
@@ -157,7 +157,7 @@ func (a *ActiveMQ) Init() error {
157157

158158
a.baseURL = u
159159

160-
a.client, err = a.createHttpClient()
160+
a.client, err = a.createHTTPClient()
161161
if err != nil {
162162
return err
163163
}
@@ -228,9 +228,9 @@ func (a *ActiveMQ) GatherSubscribersMetrics(acc telegraf.Accumulator, subscriber
228228
records := make(map[string]interface{})
229229
tags := make(map[string]string)
230230

231-
tags["client_id"] = subscriber.ClientId
231+
tags["client_id"] = subscriber.ClientID
232232
tags["subscription_name"] = subscriber.SubscriptionName
233-
tags["connection_id"] = subscriber.ConnectionId
233+
tags["connection_id"] = subscriber.ConnectionID
234234
tags["destination_name"] = subscriber.DestinationName
235235
tags["selector"] = subscriber.Selector
236236
tags["active"] = subscriber.Active

plugins/inputs/apache/apache.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error {
6767
}
6868

6969
if n.client == nil {
70-
client, err := n.createHttpClient()
70+
client, err := n.createHTTPClient()
7171
if err != nil {
7272
return err
7373
}
@@ -84,15 +84,15 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error {
8484
wg.Add(1)
8585
go func(addr *url.URL) {
8686
defer wg.Done()
87-
acc.AddError(n.gatherUrl(addr, acc))
87+
acc.AddError(n.gatherURL(addr, acc))
8888
}(addr)
8989
}
9090

9191
wg.Wait()
9292
return nil
9393
}
9494

95-
func (n *Apache) createHttpClient() (*http.Client, error) {
95+
func (n *Apache) createHTTPClient() (*http.Client, error) {
9696
tlsCfg, err := n.ClientConfig.TLSConfig()
9797
if err != nil {
9898
return nil, err
@@ -108,7 +108,7 @@ func (n *Apache) createHttpClient() (*http.Client, error) {
108108
return client, nil
109109
}
110110

111-
func (n *Apache) gatherUrl(addr *url.URL, acc telegraf.Accumulator) error {
111+
func (n *Apache) gatherURL(addr *url.URL, acc telegraf.Accumulator) error {
112112
req, err := http.NewRequest("GET", addr.String(), nil)
113113
if err != nil {
114114
return fmt.Errorf("error on new request to %s : %s", addr.String(), err)

plugins/inputs/bcache/bcache_test.go

+31-31
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ import (
1212
)
1313

1414
const (
15-
dirty_data = "1.5G"
16-
bypassed = "4.7T"
17-
cache_bypass_hits = "146155333"
18-
cache_bypass_misses = "0"
19-
cache_hit_ratio = "90"
20-
cache_hits = "511469583"
21-
cache_miss_collisions = "157567"
22-
cache_misses = "50616331"
23-
cache_readaheads = "2"
15+
dirtyData = "1.5G"
16+
bypassed = "4.7T"
17+
cacheBypassHits = "146155333"
18+
cacheBypassMisses = "0"
19+
cacheHitRatio = "90"
20+
cacheHits = "511469583"
21+
cacheMissCollisions = "157567"
22+
cacheMisses = "50616331"
23+
cacheReadaheads = "2"
2424
)
2525

2626
var (
2727
testBcachePath = os.TempDir() + "/telegraf/sys/fs/bcache"
28-
testBcacheUuidPath = testBcachePath + "/663955a3-765a-4737-a9fd-8250a7a78411"
28+
testBcacheUUIDPath = testBcachePath + "/663955a3-765a-4737-a9fd-8250a7a78411"
2929
testBcacheDevPath = os.TempDir() + "/telegraf/sys/devices/virtual/block/bcache0"
3030
testBcacheBackingDevPath = os.TempDir() + "/telegraf/sys/devices/virtual/block/md10"
3131
)
3232

3333
func TestBcacheGeneratesMetrics(t *testing.T) {
34-
err := os.MkdirAll(testBcacheUuidPath, 0755)
34+
err := os.MkdirAll(testBcacheUUIDPath, 0755)
3535
require.NoError(t, err)
3636

3737
err = os.MkdirAll(testBcacheDevPath, 0755)
@@ -40,49 +40,49 @@ func TestBcacheGeneratesMetrics(t *testing.T) {
4040
err = os.MkdirAll(testBcacheBackingDevPath+"/bcache", 0755)
4141
require.NoError(t, err)
4242

43-
err = os.Symlink(testBcacheBackingDevPath+"/bcache", testBcacheUuidPath+"/bdev0")
43+
err = os.Symlink(testBcacheBackingDevPath+"/bcache", testBcacheUUIDPath+"/bdev0")
4444
require.NoError(t, err)
4545

46-
err = os.Symlink(testBcacheDevPath, testBcacheUuidPath+"/bdev0/dev")
46+
err = os.Symlink(testBcacheDevPath, testBcacheUUIDPath+"/bdev0/dev")
4747
require.NoError(t, err)
4848

49-
err = os.MkdirAll(testBcacheUuidPath+"/bdev0/stats_total", 0755)
49+
err = os.MkdirAll(testBcacheUUIDPath+"/bdev0/stats_total", 0755)
5050
require.NoError(t, err)
5151

52-
err = ioutil.WriteFile(testBcacheUuidPath+"/bdev0/dirty_data",
53-
[]byte(dirty_data), 0644)
52+
err = ioutil.WriteFile(testBcacheUUIDPath+"/bdev0/dirty_data",
53+
[]byte(dirtyData), 0644)
5454
require.NoError(t, err)
5555

56-
err = ioutil.WriteFile(testBcacheUuidPath+"/bdev0/stats_total/bypassed",
56+
err = ioutil.WriteFile(testBcacheUUIDPath+"/bdev0/stats_total/bypassed",
5757
[]byte(bypassed), 0644)
5858
require.NoError(t, err)
5959

60-
err = ioutil.WriteFile(testBcacheUuidPath+"/bdev0/stats_total/cache_bypass_hits",
61-
[]byte(cache_bypass_hits), 0644)
60+
err = ioutil.WriteFile(testBcacheUUIDPath+"/bdev0/stats_total/cache_bypass_hits",
61+
[]byte(cacheBypassHits), 0644)
6262
require.NoError(t, err)
6363

64-
err = ioutil.WriteFile(testBcacheUuidPath+"/bdev0/stats_total/cache_bypass_misses",
65-
[]byte(cache_bypass_misses), 0644)
64+
err = ioutil.WriteFile(testBcacheUUIDPath+"/bdev0/stats_total/cache_bypass_misses",
65+
[]byte(cacheBypassMisses), 0644)
6666
require.NoError(t, err)
6767

68-
err = ioutil.WriteFile(testBcacheUuidPath+"/bdev0/stats_total/cache_hit_ratio",
69-
[]byte(cache_hit_ratio), 0644)
68+
err = ioutil.WriteFile(testBcacheUUIDPath+"/bdev0/stats_total/cache_hit_ratio",
69+
[]byte(cacheHitRatio), 0644)
7070
require.NoError(t, err)
7171

72-
err = ioutil.WriteFile(testBcacheUuidPath+"/bdev0/stats_total/cache_hits",
73-
[]byte(cache_hits), 0644)
72+
err = ioutil.WriteFile(testBcacheUUIDPath+"/bdev0/stats_total/cache_hits",
73+
[]byte(cacheHits), 0644)
7474
require.NoError(t, err)
7575

76-
err = ioutil.WriteFile(testBcacheUuidPath+"/bdev0/stats_total/cache_miss_collisions",
77-
[]byte(cache_miss_collisions), 0644)
76+
err = ioutil.WriteFile(testBcacheUUIDPath+"/bdev0/stats_total/cache_miss_collisions",
77+
[]byte(cacheMissCollisions), 0644)
7878
require.NoError(t, err)
7979

80-
err = ioutil.WriteFile(testBcacheUuidPath+"/bdev0/stats_total/cache_misses",
81-
[]byte(cache_misses), 0644)
80+
err = ioutil.WriteFile(testBcacheUUIDPath+"/bdev0/stats_total/cache_misses",
81+
[]byte(cacheMisses), 0644)
8282
require.NoError(t, err)
8383

84-
err = ioutil.WriteFile(testBcacheUuidPath+"/bdev0/stats_total/cache_readaheads",
85-
[]byte(cache_readaheads), 0644)
84+
err = ioutil.WriteFile(testBcacheUUIDPath+"/bdev0/stats_total/cache_readaheads",
85+
[]byte(cacheReadaheads), 0644)
8686
require.NoError(t, err)
8787

8888
fields := map[string]interface{}{

plugins/inputs/beanstalkd/beanstalkd.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (b *Beanstalkd) gatherServerStats(connection *textproto.Conn, acc telegraf.
128128
},
129129
map[string]string{
130130
"hostname": stats.Hostname,
131-
"id": stats.Id,
131+
"id": stats.ID,
132132
"server": b.Server,
133133
"version": stats.Version,
134134
},
@@ -169,13 +169,13 @@ func (b *Beanstalkd) gatherTubeStats(connection *textproto.Conn, tube string, ac
169169
}
170170

171171
func runQuery(connection *textproto.Conn, cmd string, result interface{}) error {
172-
requestId, err := connection.Cmd(cmd)
172+
requestID, err := connection.Cmd(cmd)
173173
if err != nil {
174174
return err
175175
}
176176

177-
connection.StartResponse(requestId)
178-
defer connection.EndResponse(requestId)
177+
connection.StartResponse(requestID)
178+
defer connection.EndResponse(requestID)
179179

180180
status, err := connection.ReadLine()
181181
if err != nil {
@@ -240,7 +240,7 @@ type statsResponse struct {
240240
CurrentWaiting int `yaml:"current-waiting"`
241241
CurrentWorkers int `yaml:"current-workers"`
242242
Hostname string `yaml:"hostname"`
243-
Id string `yaml:"id"`
243+
ID string `yaml:"id"`
244244
JobTimeouts int `yaml:"job-timeouts"`
245245
MaxJobSize int `yaml:"max-job-size"`
246246
Pid int `yaml:"pid"`

plugins/inputs/beat/beat.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,16 @@ func (beat *Beat) Gather(accumulator telegraf.Accumulator) error {
170170
beatStats := &BeatStats{}
171171
beatInfo := &BeatInfo{}
172172

173-
infoUrl, err := url.Parse(beat.URL + suffixInfo)
173+
infoURL, err := url.Parse(beat.URL + suffixInfo)
174174
if err != nil {
175175
return err
176176
}
177-
statsUrl, err := url.Parse(beat.URL + suffixStats)
177+
statsURL, err := url.Parse(beat.URL + suffixStats)
178178
if err != nil {
179179
return err
180180
}
181181

182-
err = beat.gatherJSONData(infoUrl.String(), beatInfo)
182+
err = beat.gatherJSONData(infoURL.String(), beatInfo)
183183
if err != nil {
184184
return err
185185
}
@@ -191,7 +191,7 @@ func (beat *Beat) Gather(accumulator telegraf.Accumulator) error {
191191
"beat_version": beatInfo.Version,
192192
}
193193

194-
err = beat.gatherJSONData(statsUrl.String(), beatStats)
194+
err = beat.gatherJSONData(statsURL.String(), beatStats)
195195
if err != nil {
196196
return err
197197
}

plugins/inputs/bind/bind.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ func (b *Bind) Gather(acc telegraf.Accumulator) error {
6565
wg.Add(1)
6666
go func(addr *url.URL) {
6767
defer wg.Done()
68-
acc.AddError(b.gatherUrl(addr, acc))
68+
acc.AddError(b.gatherURL(addr, acc))
6969
}(addr)
7070
}
7171

7272
wg.Wait()
7373
return nil
7474
}
7575

76-
func (b *Bind) gatherUrl(addr *url.URL, acc telegraf.Accumulator) error {
76+
func (b *Bind) gatherURL(addr *url.URL, acc telegraf.Accumulator) error {
7777
switch addr.Path {
7878
case "":
7979
// BIND 9.6 - 9.8

0 commit comments

Comments
 (0)