chore: Enable G601 rule for gosec (#13042)
This commit is contained in:
parent
55e4bb6808
commit
5f2142a6cc
|
|
@ -112,6 +112,7 @@ linters-settings:
|
|||
- G502
|
||||
- G503
|
||||
- G505
|
||||
- G601
|
||||
# To specify the configuration of rules.
|
||||
config:
|
||||
# Maximum allowed permissions mode for os.OpenFile and os.Chmod
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ func (ch *ClickHouse) Gather(acc telegraf.Accumulator) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
for _, conn := range connects {
|
||||
for i := range connects {
|
||||
metricsFuncs := []func(acc telegraf.Accumulator, conn *connect) error{
|
||||
ch.tables,
|
||||
ch.zookeeper,
|
||||
|
|
@ -141,13 +141,13 @@ func (ch *ClickHouse) Gather(acc telegraf.Accumulator) (err error) {
|
|||
}
|
||||
|
||||
for _, metricFunc := range metricsFuncs {
|
||||
if err := metricFunc(acc, &conn); err != nil {
|
||||
if err := metricFunc(acc, &connects[i]); err != nil {
|
||||
acc.AddError(err)
|
||||
}
|
||||
}
|
||||
|
||||
for metric := range commonMetrics {
|
||||
if err := ch.commonMetrics(acc, &conn, metric); err != nil {
|
||||
if err := ch.commonMetrics(acc, &connects[i], metric); err != nil {
|
||||
acc.AddError(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,7 +299,8 @@ var topDataStats = map[string]string{
|
|||
}
|
||||
|
||||
func (d *MongodbData) AddDbStats() {
|
||||
for _, dbstat := range d.StatLine.DbStatsLines {
|
||||
for i := range d.StatLine.DbStatsLines {
|
||||
dbstat := d.StatLine.DbStatsLines[i]
|
||||
dbStatLine := reflect.ValueOf(&dbstat).Elem()
|
||||
newDbData := &DbData{
|
||||
Name: dbstat.Name,
|
||||
|
|
@ -315,7 +316,8 @@ func (d *MongodbData) AddDbStats() {
|
|||
}
|
||||
|
||||
func (d *MongodbData) AddColStats() {
|
||||
for _, colstat := range d.StatLine.ColStatsLines {
|
||||
for i := range d.StatLine.ColStatsLines {
|
||||
colstat := d.StatLine.ColStatsLines[i]
|
||||
colStatLine := reflect.ValueOf(&colstat).Elem()
|
||||
newColData := &ColData{
|
||||
Name: colstat.Name,
|
||||
|
|
@ -332,7 +334,8 @@ func (d *MongodbData) AddColStats() {
|
|||
}
|
||||
|
||||
func (d *MongodbData) AddShardHostStats() {
|
||||
for host, hostStat := range d.StatLine.ShardHostStatsLines {
|
||||
for host := range d.StatLine.ShardHostStatsLines {
|
||||
hostStat := d.StatLine.ShardHostStatsLines[host]
|
||||
hostStatLine := reflect.ValueOf(&hostStat).Elem()
|
||||
newDbData := &DbData{
|
||||
Name: host,
|
||||
|
|
@ -348,7 +351,8 @@ func (d *MongodbData) AddShardHostStats() {
|
|||
}
|
||||
|
||||
func (d *MongodbData) AddTopStats() {
|
||||
for _, topStat := range d.StatLine.TopStatLines {
|
||||
for i := range d.StatLine.TopStatLines {
|
||||
topStat := d.StatLine.TopStatLines[i]
|
||||
topStatLine := reflect.ValueOf(&topStat).Elem()
|
||||
newTopStatData := &DbData{
|
||||
Name: topStat.CollectionName,
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import (
|
|||
|
||||
func TestUpdateCounters(t *testing.T) {
|
||||
ras := newRas()
|
||||
for _, mce := range testData {
|
||||
ras.updateCounters(&mce)
|
||||
for i := range testData {
|
||||
ras.updateCounters(&testData[i])
|
||||
}
|
||||
|
||||
require.Equal(t, 1, len(ras.cpuSocketCounters), "Should contain counters only for single socket")
|
||||
|
|
@ -94,8 +94,8 @@ func TestMultipleSockets(t *testing.T) {
|
|||
MciStatusMsg: overflow,
|
||||
},
|
||||
}
|
||||
for _, mce := range testData {
|
||||
ras.updateCounters(&mce)
|
||||
for i := range testData {
|
||||
ras.updateCounters(&testData[i])
|
||||
}
|
||||
require.Equal(t, 4, len(ras.cpuSocketCounters), "Should contain counters for four sockets")
|
||||
|
||||
|
|
|
|||
|
|
@ -1218,7 +1218,7 @@ func (e *Endpoint) collectChunk(
|
|||
e.log.Errorf("MOID %s not found in cache. Skipping", moid)
|
||||
continue
|
||||
}
|
||||
e.populateTags(objectRef, resourceType, res, t, &v)
|
||||
e.populateTags(objectRef, resourceType, res, t, v)
|
||||
|
||||
nValues := 0
|
||||
alignedInfo, alignedValues := e.alignSamples(em.SampleInfo, v.Value, interval)
|
||||
|
|
@ -1280,7 +1280,7 @@ func (e *Endpoint) collectChunk(
|
|||
return count, latestSample, nil
|
||||
}
|
||||
|
||||
func (e *Endpoint) populateTags(objectRef *objectRef, resourceType string, resource *resourceKind, t map[string]string, v *performance.MetricSeries) {
|
||||
func (e *Endpoint) populateTags(objectRef *objectRef, resourceType string, resource *resourceKind, t map[string]string, v performance.MetricSeries) {
|
||||
// Map name of object.
|
||||
if resource.pKey != "" {
|
||||
t[resource.pKey] = objectRef.name
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ func (a *AzureMonitor) Write(metrics []telegraf.Metric) error {
|
|||
for _, m := range azmetrics {
|
||||
// Azure Monitor accepts new batches of points in new-line delimited
|
||||
// JSON, following RFC 4288 (see https://github.com/ndjson/ndjson-spec).
|
||||
jsonBytes, err := json.Marshal(&m)
|
||||
jsonBytes, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -300,8 +300,8 @@ func writeValueList(valueLists []api.ValueList) (*network.Buffer, error) {
|
|||
buffer := network.NewBuffer(0)
|
||||
|
||||
ctx := context.Background()
|
||||
for _, vl := range valueLists {
|
||||
err := buffer.Write(ctx, &vl)
|
||||
for i := range valueLists {
|
||||
err := buffer.Write(ctx, &valueLists[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue