Skip to content

Commit

Permalink
lint (copyloopvar) (#2971)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc authored Jun 20, 2024
1 parent a1ebe18 commit 8a259fd
Show file tree
Hide file tree
Showing 31 changed files with 0 additions and 79 deletions.
3 changes: 0 additions & 3 deletions pkg/acquisition/acquisition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ wowo: ajsajasjas
}

for _, tc := range tests {
tc := tc
t.Run(tc.TestName, func(t *testing.T) {
common := configuration.DataSourceCommonCfg{}
yaml.Unmarshal([]byte(tc.String), &common)
Expand Down Expand Up @@ -282,7 +281,6 @@ func TestLoadAcquisitionFromFile(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.TestName, func(t *testing.T) {
dss, err := LoadAcquisitionFromFile(&tc.Config, nil)
cstest.RequireErrorContains(t, err, tc.ExpectedError)
Expand Down Expand Up @@ -549,7 +547,6 @@ func TestConfigureByDSN(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.dsn, func(t *testing.T) {
srcs, err := LoadAcquisitionFromDSN(tc.dsn, map[string]string{"type": "test_label"}, "")
cstest.RequireErrorContains(t, err, tc.ExpectedError)
Expand Down
1 change: 0 additions & 1 deletion pkg/acquisition/modules/appsec/appsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ func (w *AppsecSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb)

w.logger.Infof("%d appsec runner to start", len(w.AppsecRunners))
for _, runner := range w.AppsecRunners {
runner := runner
runner.outChan = out
t.Go(func() error {
defer trace.CatchPanic("crowdsec/acquis/appsec/live/runner")
Expand Down
4 changes: 0 additions & 4 deletions pkg/acquisition/modules/cloudwatch/cloudwatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ stream_name: test_stream`),
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
dbgLogger := log.New().WithField("test", tc.name)
dbgLogger.Logger.SetLevel(log.DebugLevel)
Expand Down Expand Up @@ -556,7 +555,6 @@ stream_name: test_stream`),
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
dbgLogger := log.New().WithField("test", tc.name)
dbgLogger.Logger.SetLevel(log.DebugLevel)
Expand Down Expand Up @@ -621,7 +619,6 @@ func TestConfigureByDSN(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
dbgLogger := log.New().WithField("test", tc.name)
dbgLogger.Logger.SetLevel(log.DebugLevel)
Expand Down Expand Up @@ -743,7 +740,6 @@ func TestOneShotAcquisition(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
dbgLogger := log.New().WithField("test", tc.name)
dbgLogger.Logger.SetLevel(log.DebugLevel)
Expand Down
4 changes: 0 additions & 4 deletions pkg/acquisition/modules/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ exclude_regexps: ["as[a-$d"]`,
subLogger := log.WithField("type", "file")

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
f := fileacquisition.FileSource{}
err := f.Configure([]byte(tc.config), subLogger, configuration.METRICS_NONE)
Expand Down Expand Up @@ -92,7 +91,6 @@ func TestConfigureDSN(t *testing.T) {
subLogger := log.WithField("type", "file")

for _, tc := range tests {
tc := tc
t.Run(tc.dsn, func(t *testing.T) {
f := fileacquisition.FileSource{}
err := f.ConfigureByDSN(tc.dsn, map[string]string{"type": "testtype"}, subLogger, "")
Expand Down Expand Up @@ -202,7 +200,6 @@ filename: test_files/test_delete.log`,
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
logger, hook := test.NewNullLogger()
logger.SetLevel(tc.logLevel)
Expand Down Expand Up @@ -361,7 +358,6 @@ force_inotify: true`, testPattern),
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
logger, hook := test.NewNullLogger()
logger.SetLevel(tc.logLevel)
Expand Down
2 changes: 0 additions & 2 deletions pkg/acquisition/modules/kafka/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func TestStreamingAcquisition(t *testing.T) {
}

for _, ts := range tests {
ts := ts
t.Run(ts.name, func(t *testing.T) {
k := KafkaSource{}

Expand Down Expand Up @@ -233,7 +232,6 @@ func TestStreamingAcquisitionWithSSL(t *testing.T) {
}

for _, ts := range tests {
ts := ts
t.Run(ts.name, func(t *testing.T) {
k := KafkaSource{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func TestPri(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.input, func(t *testing.T) {
r := &RFC3164{}
r.buf = []byte(test.input)
Expand Down Expand Up @@ -64,7 +63,6 @@ func TestTimestamp(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.input, func(t *testing.T) {
opts := []RFC3164Option{}
if test.currentYear {
Expand Down Expand Up @@ -118,7 +116,6 @@ func TestHostname(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.input, func(t *testing.T) {
opts := []RFC3164Option{}
if test.strictHostname {
Expand Down Expand Up @@ -163,7 +160,6 @@ func TestTag(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.input, func(t *testing.T) {
r := &RFC3164{}
r.buf = []byte(test.input)
Expand Down Expand Up @@ -207,7 +203,6 @@ func TestMessage(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.input, func(t *testing.T) {
r := &RFC3164{}
r.buf = []byte(test.input)
Expand Down Expand Up @@ -329,7 +324,6 @@ func TestParse(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.input, func(t *testing.T) {
r := NewRFC3164Parser(test.opts...)
err := r.Parse([]byte(test.input))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func BenchmarkParse(b *testing.B) {
}
var err error
for _, test := range tests {
test := test
b.Run(string(test.input), func(b *testing.B) {
for i := 0; i < b.N; i++ {
r := NewRFC3164Parser(test.opts...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func TestPri(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.input, func(t *testing.T) {
r := &RFC5424{}
r.buf = []byte(test.input)
Expand Down Expand Up @@ -61,7 +60,6 @@ func TestHostname(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.input, func(t *testing.T) {
opts := []RFC5424Option{}
if test.strictHostname {
Expand Down Expand Up @@ -200,7 +198,6 @@ func TestParse(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
r := NewRFC5424Parser(test.opts...)
err := r.Parse([]byte(test.input))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func BenchmarkParse(b *testing.B) {
}
var err error
for _, test := range tests {
test := test
b.Run(test.label, func(b *testing.B) {
for i := 0; i < b.N; i++ {
r := NewRFC5424Parser()
Expand Down
1 change: 0 additions & 1 deletion pkg/acquisition/modules/syslog/syslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ listen_addr: 127.0.0.1`,
}

for _, ts := range tests {
ts := ts
t.Run(ts.name, func(t *testing.T) {
subLogger := log.WithField("type", "syslog")
s := SyslogSource{}
Expand Down
1 change: 0 additions & 1 deletion pkg/apiclient/decisions_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ func TestDecisionsStreamOpts_addQueryParamsToURL(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
o := &DecisionsStreamOpts{
Startup: tt.fields.Startup,
Expand Down
1 change: 0 additions & 1 deletion pkg/apiserver/apic_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func TestAPICSendMetrics(t *testing.T) {
defer httpmock.Deactivate()

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
url, err := url.ParseRequestURI("http://api.crowdsec.net/")
require.NoError(t, err)
Expand Down
7 changes: 0 additions & 7 deletions pkg/apiserver/apic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ func TestAPICFetchScenariosListFromDB(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
api := getAPIC(t)
for machineID, scenarios := range tc.machineIDsWithScenarios {
Expand Down Expand Up @@ -233,7 +232,6 @@ func TestNewAPIC(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
setConfig()
httpmock.Activate()
Expand Down Expand Up @@ -353,7 +351,6 @@ func TestAPICGetMetrics(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
apiClient := getAPIC(t)
cleanUp(apiClient)
Expand Down Expand Up @@ -461,7 +458,6 @@ func TestCreateAlertsForDecision(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if got := createAlertsForDecisions(tc.args.decisions); !reflect.DeepEqual(got, tc.want) {
t.Errorf("createAlertsForDecisions() = %v, want %v", got, tc.want)
Expand Down Expand Up @@ -541,7 +537,6 @@ func TestFillAlertsWithDecisions(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
addCounters, _ := makeAddAndDeleteCounters()
if got := fillAlertsWithDecisions(tc.args.alerts, tc.args.decisions, addCounters); !reflect.DeepEqual(got, tc.want) {
Expand Down Expand Up @@ -1159,7 +1154,6 @@ func TestAPICPull(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
api = getAPIC(t)
api.pullInterval = time.Millisecond
Expand Down Expand Up @@ -1286,7 +1280,6 @@ func TestShouldShareAlert(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
ret := shouldShareAlert(tc.alert, tc.consoleConfig)
assert.Equal(t, tc.expectedRet, ret)
Expand Down
4 changes: 0 additions & 4 deletions pkg/csconfig/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func TestLoadLocalApiClientCfg(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.input.Load()
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down Expand Up @@ -122,7 +121,6 @@ func TestLoadOnlineApiClientCfg(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.input.Load()
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down Expand Up @@ -245,7 +243,6 @@ func TestLoadAPIServer(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.input.LoadAPIServer(false)
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down Expand Up @@ -309,7 +306,6 @@ func TestParseCapiWhitelists(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
wl, err := parseCapiWhitelists(strings.NewReader(tc.input))
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down
1 change: 0 additions & 1 deletion pkg/csconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func TestNewCrowdSecConfig(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
result := &Config{}
assert.Equal(t, tc.expected, result)
Expand Down
1 change: 0 additions & 1 deletion pkg/csconfig/crowdsec_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ func TestLoadCrowdsec(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.input.LoadCrowdsec()
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down
1 change: 0 additions & 1 deletion pkg/csconfig/cscli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestLoadCSCLI(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.input.loadCSCLI()
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down
1 change: 0 additions & 1 deletion pkg/csconfig/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func TestLoadDBConfig(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.input.LoadDBConfig(false)
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down
1 change: 0 additions & 1 deletion pkg/csconfig/hub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func TestLoadHub(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.input.loadHub()
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down
2 changes: 0 additions & 2 deletions pkg/csconfig/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func TestSimulationLoading(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.input.LoadSimulation()
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down Expand Up @@ -124,7 +123,6 @@ func TestIsSimulated(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
isSimulated := tc.SimulationConfig.IsSimulated(tc.Input)
require.Equal(t, tc.expected, isSimulated)
Expand Down
1 change: 0 additions & 1 deletion pkg/csplugin/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ func (s *PluginSuite) TestBrokerInit() {
}

for _, tc := range tests {
tc := tc
s.Run(tc.name, func() {
t := s.T()
if tc.action != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/csplugin/listfiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func TestListFilesAtPath(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
got, err := listFilesAtPath(tc.path)
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down
1 change: 0 additions & 1 deletion pkg/csplugin/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestGetPluginNameAndTypeFromPath(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
got, got1, err := getPluginTypeAndSubtypeFromPath(tc.path)
cstest.RequireErrorContains(t, err, tc.expectedErr)
Expand Down
Loading

0 comments on commit 8a259fd

Please sign in to comment.