test: remove redundant loop variable capture in builder_test.go#3675
test: remove redundant loop variable capture in builder_test.go#3675Ankitsinghsisodya wants to merge 1 commit intoknative:mainfrom
Conversation
Eliminate the redundant variable declaration within the test case loop in TestBuild_Errors to improve code clarity and maintainability.
|
Hi @Ankitsinghsisodya. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Pull request overview
This PR updates a table-driven, parallel subtest in pkg/buildpacks/builder_test.go by removing the now-unnecessary Go loop-variable shadowing (tc := tc) in TestBuild_Errors, relying on Go 1.22+ per-iteration loop variable semantics (the repo’s go.mod targets Go 1.25.9).
Changes:
- Remove redundant
tc := tccapture insidet.Runclosures inTestBuild_Errors. - Keep
t.Parallel()behavior intact while simplifying the test loop.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3675 +/- ##
==========================================
+ Coverage 56.61% 56.63% +0.01%
==========================================
Files 181 181
Lines 20853 20853
==========================================
+ Hits 11806 11810 +4
+ Misses 7833 7831 -2
+ Partials 1214 1212 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Ankitsinghsisodya, lkingland The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Thanks And this appears to be the only remaining instance of this pattern which remained in the codebase. |
Yes sir, I have verified this was the last one following the legacy pattern. |
Summary
Remove the redundant
tc := tcloop variable capture fromTestBuild_Errorsinpkg/buildpacks/builder_test.go.Since Go 1.22, each loop iteration gets its own copy of the loop variable automatically, making the explicit shadowing idiom unnecessary. This project uses Go 1.25, so the pattern is dead code.
Changes
pkg/buildpacks/builder_test.go: removetc := tcfrom theTestBuild_Errorstable-driven test loopTesting