Remove unnecessary copies of loop variables (#28138)

Этот коммит содержится в:
Ben Schumacher
2024-09-11 16:51:30 +02:00
коммит произвёл GitHub
родитель b6bd92f90e
Коммит d9e47522a0
13 изменённых файлов: 0 добавлений и 24 удалений

Просмотреть файл

@@ -18,7 +18,6 @@ linters:
- govet
- ineffassign
- revive
- exportloopref
- staticcheck
- unconvert
- unused

Просмотреть файл

@@ -2493,7 +2493,6 @@ func TestIsCRTEnabledForUser(t *testing.T) {
}
for _, tc := range testCases {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
th := SetupWithStoreMock(t)
defer th.TearDown()

Просмотреть файл

@@ -57,8 +57,6 @@ func TestMetricsRouter(t *testing.T) {
"pprof trace": {path: "/debug/pprof/trace"},
} {
t.Run(name, func(t *testing.T) {
name := name // TODO: Remove once go1.22 is used
tc := tc // TODO: Remove once go1.22 is used
t.Parallel()
method := http.MethodGet

Просмотреть файл

@@ -1472,7 +1472,6 @@ func TestGetEmojiNamesForString(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
emojis := getEmojiNamesForString(testCase.Input)
assert.ElementsMatch(t, emojis, testCase.Expected, "received incorrect emoji names")
@@ -1568,7 +1567,6 @@ func TestGetEmojiNamesForPost(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
emojis := getEmojiNamesForPost(testCase.Post, testCase.Reactions)
assert.ElementsMatch(t, emojis, testCase.Expected, "received incorrect emoji names")
@@ -2829,7 +2827,6 @@ func TestContainsPermalink(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
actual := th.App.containsPermalink(th.Context, testCase.Post)
assert.Equal(t, testCase.Expected, actual)

Просмотреть файл

@@ -757,7 +757,6 @@ func TestMaxPostSize(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
mockStore := &storetest.Store{}
defer mockStore.AssertExpectations(t)

Просмотреть файл

@@ -277,7 +277,6 @@ func TestGetReplica(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description+" with license", func(t *testing.T) {
settings, err := makeSqlSettings(model.DatabaseDriverPostgres)
if err != nil {
@@ -647,7 +646,6 @@ func TestGetAllConns(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
t.Parallel()
settings, err := makeSqlSettings(model.DatabaseDriverPostgres)

Просмотреть файл

@@ -272,7 +272,6 @@ func TestRoundOffToZeroes(t *testing.T) {
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
res := RoundOffToZeroes(tc.n)
assert.Equal(t, tc.expected, res)
@@ -427,7 +426,6 @@ func TestRoundOffToZeroesResolution(t *testing.T) {
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
res := RoundOffToZeroesResolution(tc.n, tc.minResolution)
assert.Equal(t, tc.expected, res)

Просмотреть файл

@@ -480,7 +480,6 @@ func TestParamsFromRequest(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
t.Parallel()

Просмотреть файл

@@ -135,8 +135,6 @@ func TestFetchAndComplete(t *testing.T) {
},
} {
t.Run(name, func(t *testing.T) {
name := name // TODO: Remove once go1.22 is used
tc := tc // TODO: Remove once go1.22 is used
t.Parallel()
comp, directive := fetchAndComplete[user](tc.fetcher, tc.matcher)(context.Background(), nil, nil, nil, tc.toComplete)

Просмотреть файл

@@ -322,7 +322,6 @@ func TestGetClientConfig(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.description, func(t *testing.T) {
t.Parallel()
@@ -414,7 +413,6 @@ func TestGetLimitedClientConfig(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.description, func(t *testing.T) {
t.Parallel()

Просмотреть файл

@@ -204,7 +204,6 @@ func TestCommandResponseFromJSON(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
t.Parallel()

Просмотреть файл

@@ -963,7 +963,6 @@ func TestNowhereNil(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
defer func() {
if r := recover(); r != nil {
@@ -1196,7 +1195,6 @@ func TestIsValidHTTPURL(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
defer func() {
if r := recover(); r != nil {

Просмотреть файл

@@ -62,7 +62,6 @@ func TestHumanizeJsonError(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
actual := utils.HumanizeJSONError(testCase.Err, testCase.Data)
if testCase.ExpectedErr == "" {
@@ -222,7 +221,6 @@ func TestNewHumanizedJSONError(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
actual := utils.NewHumanizedJSONError(testCase.Err, testCase.Data, testCase.Offset)
if testCase.Expected != nil && actual.Err != nil {
@@ -291,7 +289,6 @@ func TestIsJSONEmpty(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
empty := utils.IsEmptyJSON(testCase.Data)
assert.Equal(t, testCase.Empty, empty)
@@ -348,7 +345,6 @@ func TestStringPtrToJSON(t *testing.T) {
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Description, func(t *testing.T) {
j := utils.StringPtrToJSON(testCase.Ptr)
assert.Equal(t, testCase.Expect, j)