Skip to content

test: remove redundant loop variable capture in builder_test.go#3675

Open
Ankitsinghsisodya wants to merge 1 commit intoknative:mainfrom
Ankitsinghsisodya:remove-tc-capture
Open

test: remove redundant loop variable capture in builder_test.go#3675
Ankitsinghsisodya wants to merge 1 commit intoknative:mainfrom
Ankitsinghsisodya:remove-tc-capture

Conversation

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor

Summary

Remove the redundant tc := tc loop variable capture from TestBuild_Errors in pkg/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: remove tc := tc from the TestBuild_Errors table-driven test loop

Testing

make test

Eliminate the redundant variable declaration within the test case loop in TestBuild_Errors to improve code clarity and maintainability.
Copilot AI review requested due to automatic review settings May 7, 2026 20:43
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 7, 2026 20:43
@knative-prow knative-prow Bot added size/XS 🤖 PR changes 0-9 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 7, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 7, 2026

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 := tc capture inside t.Run closures in TestBuild_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
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.63%. Comparing base (33a9d85) to head (92ee537).
⚠️ Report is 3 commits behind head on main.

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     
Flag Coverage Δ
e2e 36.25% <ø> (-0.01%) ⬇️
e2e go 32.91% <ø> (ø)
e2e node 28.64% <ø> (+0.02%) ⬆️
e2e python 33.28% <ø> (ø)
e2e quarkus 28.76% <ø> (ø)
e2e rust 28.14% <ø> (-0.03%) ⬇️
e2e springboot 26.61% <ø> (-0.03%) ⬇️
e2e typescript 28.73% <ø> (ø)
e2e-config-ci 17.98% <ø> (ø)
integration 17.36% <ø> (+0.03%) ⬆️
unit macos-14 44.65% <ø> (ø)
unit macos-latest 44.65% <ø> (ø)
unit ubuntu-24.04-arm 44.90% <ø> (ø)
unit ubuntu-latest 45.51% <ø> (ø)
unit windows-latest 44.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label May 8, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 8, 2026

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved 🤖 PR has been approved by an approver from all required OWNERS files. label May 8, 2026
@lkingland
Copy link
Copy Markdown
Member

Thanks

And this appears to be the only remaining instance of this pattern which remained in the codebase.

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. lgtm 🤖 PR is ready to be merged. needs-ok-to-test 🤖 Needs an org member to approve testing size/XS 🤖 PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants