Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove copied loop vars #14383

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ linters:
- govet
- typecheck
- depguard
- exportloopref
- copyloopvar
- gofmt
- goimports
- gosimple
Expand Down
1 change: 0 additions & 1 deletion clients/pkg/logentry/metric/counters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func Test_validateCounterConfig(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
err := validateCounterConfig(&tt.config)
Expand Down
2 changes: 0 additions & 2 deletions clients/pkg/logentry/stages/decolorize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ func TestPipeline_Decolorize(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 0 additions & 4 deletions clients/pkg/logentry/stages/eventlogmessage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func TestEventLogMessage_simple(t *testing.T) {
}

for testName, testData := range tests {
testData := testData
testData.extractedValues[testData.sourcekey] = testData.msgdata

t.Run(testName, func(t *testing.T) {
Expand Down Expand Up @@ -151,7 +150,6 @@ func TestEventLogMessageConfig_validate(t *testing.T) {
},
}
for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
_, err := newEventLogMessageStage(util_log.Logger, tt.config)
if tt.err != nil {
Expand Down Expand Up @@ -262,7 +260,6 @@ func TestEventLogMessage_Real(t *testing.T) {
}

for testName, testData := range tests {
testData := testData
testData.extractedValues[testData.sourcekey] = testData.msgdata

t.Run(testName, func(t *testing.T) {
Expand Down Expand Up @@ -318,7 +315,6 @@ func TestEventLogMessage_invalid(t *testing.T) {
}

for testName, testData := range tests {
testData := testData
testData.extractedValues[testData.sourcekey] = testData.msgdata

t.Run(testName, func(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions clients/pkg/logentry/stages/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func TestNewDocker(t *testing.T) {
}

for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
t.Parallel()
p, err := NewDocker(util_log.Logger, prometheus.DefaultRegisterer)
Expand Down Expand Up @@ -268,7 +267,6 @@ func TestNewCri(t *testing.T) {
}

for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
t.Parallel()
cfg := map[string]interface{}{}
Expand Down
4 changes: 0 additions & 4 deletions clients/pkg/logentry/stages/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ func TestPipeline_JSON(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -179,7 +177,6 @@ func TestJSONConfig_validate(t *testing.T) {
},
}
for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
c, err := parseJSONConfig(tt.config)
assert.NoError(t, err, "failed to create config: %s", err)
Expand Down Expand Up @@ -339,7 +336,6 @@ func TestJSONParser_Parse(t *testing.T) {
},
}
for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
t.Parallel()
p, err := New(util_log.Logger, nil, StageTypeJSON, tt.config, nil)
Expand Down
2 changes: 0 additions & 2 deletions clients/pkg/logentry/stages/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func TestLabels(t *testing.T) {
},
}
for name, test := range tests {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
err := validateLabelsConfig(test.config)
Expand Down Expand Up @@ -176,7 +175,6 @@ func TestLabelStage_Process(t *testing.T) {
},
}
for name, test := range tests {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
st, err := newLabelStage(util_log.Logger, test.config)
Expand Down
4 changes: 0 additions & 4 deletions clients/pkg/logentry/stages/logfmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ func TestPipeline_Logfmt(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -153,7 +151,6 @@ func TestLogfmtConfig_validate(t *testing.T) {
},
}
for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
c, err := parseLogfmtConfig(tt.config)
assert.NoError(t, err)
Expand Down Expand Up @@ -281,7 +278,6 @@ func TestLogfmtParser_Parse(t *testing.T) {
},
}
for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
t.Parallel()
p, err := New(util_log.Logger, nil, StageTypeLogfmt, tt.config, nil)
Expand Down
1 change: 0 additions & 1 deletion clients/pkg/logentry/stages/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ func TestValidateMetricsConfig(t *testing.T) {
}

for name, test := range tests {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
err := validateMetricsConfig(test.config)
Expand Down
2 changes: 0 additions & 2 deletions clients/pkg/logentry/stages/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func TestOutputValidation(t *testing.T) {
},
}
for name, test := range tests {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
err := validateOutputConfig(test.config)
Expand Down Expand Up @@ -120,7 +119,6 @@ func TestOutputStage_Process(t *testing.T) {
},
}
for name, test := range tests {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
st, err := newOutputStage(util_log.Logger, test.config)
Expand Down
3 changes: 0 additions & 3 deletions clients/pkg/logentry/stages/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ func TestPipeline_Process(t *testing.T) {
}

for tName, tt := range tests {
tt := tt

t.Run(tName, func(t *testing.T) {
var config map[string]interface{}

Expand Down Expand Up @@ -304,7 +302,6 @@ func TestPipeline_Wrap(t *testing.T) {
}

for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
t.Parallel()
c := fake.New(func() {})
Expand Down
4 changes: 0 additions & 4 deletions clients/pkg/logentry/stages/regex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ func TestPipeline_Regex(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -204,7 +202,6 @@ func TestRegexConfig_validate(t *testing.T) {
},
}
for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
c, err := parseRegexConfig(tt.config)
if err != nil {
Expand Down Expand Up @@ -322,7 +319,6 @@ func TestRegexParser_Parse(t *testing.T) {
},
}
for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
t.Parallel()
p, err := New(util_log.Logger, nil, StageTypeRegex, tt.config, nil)
Expand Down
3 changes: 0 additions & 3 deletions clients/pkg/logentry/stages/replace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ func TestPipeline_Replace(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -252,7 +250,6 @@ func TestReplaceConfig_validate(t *testing.T) {
},
}
for tName, tt := range tests {
tt := tt
t.Run(tName, func(t *testing.T) {
c, err := parseReplaceConfig(tt.config)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions clients/pkg/logentry/stages/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func TestTemplateValidation(t *testing.T) {
},
}
for name, test := range tests {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
_, err := validateTemplateConfig(test.config)
Expand Down Expand Up @@ -375,7 +374,6 @@ func TestTemplateStage_Process(t *testing.T) {
},
}
for name, test := range tests {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
st, err := newTemplateStage(util_log.Logger, test.config)
Expand Down
4 changes: 0 additions & 4 deletions clients/pkg/logentry/stages/tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ func TestTenantStage_Validation(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
stage, err := newTenantStage(util_log.Logger, testData.config)

Expand Down Expand Up @@ -202,8 +200,6 @@ func TestTenantStage_Process(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
stage, err := newTenantStage(util_log.Logger, testData.config)
require.NoError(t, err)
Expand Down
4 changes: 0 additions & 4 deletions clients/pkg/logentry/stages/timestamp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ func TestTimestampValidation(t *testing.T) {
},
}
for name, test := range tests {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
parser, err := validateTimestampConfig(test.config)
Expand Down Expand Up @@ -295,7 +294,6 @@ func TestTimestampStage_Process(t *testing.T) {
},
}
for name, test := range tests {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
st, err := newTimestampStage(util_log.Logger, test.config)
Expand Down Expand Up @@ -431,8 +429,6 @@ func TestTimestampStage_ProcessActionOnFailure(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 0 additions & 4 deletions clients/pkg/logentry/stages/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ func TestConvertDateLayout(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -224,8 +222,6 @@ func TestParseTimestampWithoutYear(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 0 additions & 4 deletions clients/pkg/promtail/client/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ func TestBatch_add(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
b := newBatch(0)

Expand Down Expand Up @@ -123,8 +121,6 @@ func TestBatch_encode(t *testing.T) {
}

for testName, testData := range tests {
testData := testData

t.Run(testName, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion clients/pkg/promtail/client/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func Test_Config(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
err := yaml.Unmarshal([]byte(tc.configValues), &clientConfig)

if tc.expectedErr != nil {
Expand Down
1 change: 0 additions & 1 deletion clients/pkg/promtail/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func TestConfig_Setup(t *testing.T) {
},
},
} {
tt := tt
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
tt.in.Setup(log.NewNopLogger())
require.Equal(t, tt.expected, tt.in)
Expand Down
1 change: 0 additions & 1 deletion clients/pkg/promtail/targets/kafka/target_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func Test_validateConfig(t *testing.T) {
}

for i, tt := range tests {
tt := tt
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
err := validateConfig(tt.cfg)
if (err != nil) != tt.wantErr {
Expand Down
2 changes: 0 additions & 2 deletions clients/pkg/promtail/targets/kafka/topics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func Test_NewTopicManager(t *testing.T) {
false,
},
} {
tt := tt
t.Run(strings.Join(tt.in, ","), func(t *testing.T) {
t.Parallel()
_, err := newTopicManager(&mockKafkaClient{}, tt.in)
Expand Down Expand Up @@ -86,7 +85,6 @@ func Test_Topics(t *testing.T) {
false,
},
} {
tt := tt
t.Run("", func(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 0 additions & 3 deletions clients/pkg/promtail/targets/syslog/syslogtarget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ func Benchmark_SyslogTarget(b *testing.B) {
{"tcp", protocolTCP, fmtOctetCounting},
{"udp", protocolUDP, fmtOctetCounting},
} {
tt := tt
b.Run(tt.name, func(b *testing.B) {
client := fake.New(func() {})

Expand Down Expand Up @@ -366,7 +365,6 @@ func TestSyslogTarget(t *testing.T) {
{"udp newline separated", protocolUDP, fmtNewline},
{"udp octetcounting", protocolUDP, fmtOctetCounting},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
w := log.NewSyncWriter(os.Stderr)
logger := log.NewLogfmtLogger(w)
Expand Down Expand Up @@ -481,7 +479,6 @@ func TestSyslogTarget_RFC5424Messages(t *testing.T) {
{"tcp newline separated", protocolTCP, fmtNewline},
{"tcp octetcounting", protocolTCP, fmtOctetCounting},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
w := log.NewSyncWriter(os.Stderr)
logger := log.NewLogfmtLogger(w)
Expand Down
2 changes: 0 additions & 2 deletions pkg/bloombuild/builder/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func TestBatchedLoader(t *testing.T) {
inputs: [][]int{{0}},
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
fetchers := make([]Fetcher[int, int], 0, len(tc.inputs))
for range tc.inputs {
Expand Down Expand Up @@ -193,7 +192,6 @@ func TestOverlappingBlocksIter(t *testing.T) {
exp: 2,
},
} {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
it := overlappingBlocksIter(tc.inp)
var overlapping [][]bloomshipper.BlockRef
Expand Down
Loading
Loading