Remove unnecessary copies of loop variables (#28138)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b6bd92f90e
Коммит
d9e47522a0
@@ -18,7 +18,6 @@ linters:
|
|||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- revive
|
- revive
|
||||||
- exportloopref
|
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- unconvert
|
- unconvert
|
||||||
- unused
|
- unused
|
||||||
|
|||||||
@@ -2493,7 +2493,6 @@ func TestIsCRTEnabledForUser(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
th := SetupWithStoreMock(t)
|
th := SetupWithStoreMock(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ func TestMetricsRouter(t *testing.T) {
|
|||||||
"pprof trace": {path: "/debug/pprof/trace"},
|
"pprof trace": {path: "/debug/pprof/trace"},
|
||||||
} {
|
} {
|
||||||
t.Run(name, func(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()
|
t.Parallel()
|
||||||
|
|
||||||
method := http.MethodGet
|
method := http.MethodGet
|
||||||
|
|||||||
@@ -1472,7 +1472,6 @@ func TestGetEmojiNamesForString(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
emojis := getEmojiNamesForString(testCase.Input)
|
emojis := getEmojiNamesForString(testCase.Input)
|
||||||
assert.ElementsMatch(t, emojis, testCase.Expected, "received incorrect emoji names")
|
assert.ElementsMatch(t, emojis, testCase.Expected, "received incorrect emoji names")
|
||||||
@@ -1568,7 +1567,6 @@ func TestGetEmojiNamesForPost(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
emojis := getEmojiNamesForPost(testCase.Post, testCase.Reactions)
|
emojis := getEmojiNamesForPost(testCase.Post, testCase.Reactions)
|
||||||
assert.ElementsMatch(t, emojis, testCase.Expected, "received incorrect emoji names")
|
assert.ElementsMatch(t, emojis, testCase.Expected, "received incorrect emoji names")
|
||||||
@@ -2829,7 +2827,6 @@ func TestContainsPermalink(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
actual := th.App.containsPermalink(th.Context, testCase.Post)
|
actual := th.App.containsPermalink(th.Context, testCase.Post)
|
||||||
assert.Equal(t, testCase.Expected, actual)
|
assert.Equal(t, testCase.Expected, actual)
|
||||||
|
|||||||
@@ -757,7 +757,6 @@ func TestMaxPostSize(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
mockStore := &storetest.Store{}
|
mockStore := &storetest.Store{}
|
||||||
defer mockStore.AssertExpectations(t)
|
defer mockStore.AssertExpectations(t)
|
||||||
|
|||||||
@@ -277,7 +277,6 @@ func TestGetReplica(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description+" with license", func(t *testing.T) {
|
t.Run(testCase.Description+" with license", func(t *testing.T) {
|
||||||
settings, err := makeSqlSettings(model.DatabaseDriverPostgres)
|
settings, err := makeSqlSettings(model.DatabaseDriverPostgres)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -647,7 +646,6 @@ func TestGetAllConns(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
settings, err := makeSqlSettings(model.DatabaseDriverPostgres)
|
settings, err := makeSqlSettings(model.DatabaseDriverPostgres)
|
||||||
|
|||||||
@@ -272,7 +272,6 @@ func TestRoundOffToZeroes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
res := RoundOffToZeroes(tc.n)
|
res := RoundOffToZeroes(tc.n)
|
||||||
assert.Equal(t, tc.expected, res)
|
assert.Equal(t, tc.expected, res)
|
||||||
@@ -427,7 +426,6 @@ func TestRoundOffToZeroesResolution(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
res := RoundOffToZeroesResolution(tc.n, tc.minResolution)
|
res := RoundOffToZeroesResolution(tc.n, tc.minResolution)
|
||||||
assert.Equal(t, tc.expected, res)
|
assert.Equal(t, tc.expected, res)
|
||||||
|
|||||||
@@ -480,7 +480,6 @@ func TestParamsFromRequest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -135,8 +135,6 @@ func TestFetchAndComplete(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(name, func(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()
|
t.Parallel()
|
||||||
|
|
||||||
comp, directive := fetchAndComplete[user](tc.fetcher, tc.matcher)(context.Background(), nil, nil, nil, tc.toComplete)
|
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 {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.description, func(t *testing.T) {
|
t.Run(testCase.description, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -414,7 +413,6 @@ func TestGetLimitedClientConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.description, func(t *testing.T) {
|
t.Run(testCase.description, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,6 @@ func TestCommandResponseFromJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -963,7 +963,6 @@ func TestNowhereNil(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
@@ -1196,7 +1195,6 @@ func TestIsValidHTTPURL(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ func TestHumanizeJsonError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
actual := utils.HumanizeJSONError(testCase.Err, testCase.Data)
|
actual := utils.HumanizeJSONError(testCase.Err, testCase.Data)
|
||||||
if testCase.ExpectedErr == "" {
|
if testCase.ExpectedErr == "" {
|
||||||
@@ -222,7 +221,6 @@ func TestNewHumanizedJSONError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
actual := utils.NewHumanizedJSONError(testCase.Err, testCase.Data, testCase.Offset)
|
actual := utils.NewHumanizedJSONError(testCase.Err, testCase.Data, testCase.Offset)
|
||||||
if testCase.Expected != nil && actual.Err != nil {
|
if testCase.Expected != nil && actual.Err != nil {
|
||||||
@@ -291,7 +289,6 @@ func TestIsJSONEmpty(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
empty := utils.IsEmptyJSON(testCase.Data)
|
empty := utils.IsEmptyJSON(testCase.Data)
|
||||||
assert.Equal(t, testCase.Empty, empty)
|
assert.Equal(t, testCase.Empty, empty)
|
||||||
@@ -348,7 +345,6 @@ func TestStringPtrToJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
t.Run(testCase.Description, func(t *testing.T) {
|
||||||
j := utils.StringPtrToJSON(testCase.Ptr)
|
j := utils.StringPtrToJSON(testCase.Ptr)
|
||||||
assert.Equal(t, testCase.Expect, j)
|
assert.Equal(t, testCase.Expect, j)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user