Skip to content

Potential fix for code scanning alert no. 56: Unused variable, import, function or class - #807

Merged
jonobr1 merged 2 commits into
devfrom
alert-autofix-56
Apr 6, 2026
Merged

Potential fix for code scanning alert no. 56: Unused variable, import, function or class#807
jonobr1 merged 2 commits into
devfrom
alert-autofix-56

Conversation

@jonobr1

@jonobr1 jonobr1 commented Apr 6, 2026

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/jonobr1/two.js/security/code-scanning/56

In general, unused variables should either be removed entirely or, if their initialization side effects are required, the initialization should be kept without binding the result to a name. Here, we want to avoid changing behavior: the construction of new Two({...}).appendTo(document.body); should still run, but the unused binding var two = should be removed so there is no unused variable.

The best fix is therefore to replace var two = new Two({ ... }).appendTo(document.body); with a bare expression new Two({ ... }).appendTo(document.body); in the Texture.dispose - Event Unbinding test. This keeps the renderer/DOM setup side effects but eliminates the unused two variable. No new imports, methods, or definitions are required. Concretely, in tests/suite/dispose.js, around line 1145–1150, update that single declaration line to remove var two =.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…, function or class

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@codacy-production

codacy-production Bot commented Apr 6, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 duplication

Metric Results
Duplication 4

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@jonobr1
jonobr1 marked this pull request as ready for review April 6, 2026 18:00
Copilot AI review requested due to automatic review settings April 6, 2026 18:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Removes an unused two variable binding in a dispose test to address a code scanning alert while preserving the side effects of creating/appending a Two instance.

Changes:

  • Replaces var two = ... with a bare new Two(...) expression in the Texture.dispose - Event Unbinding test.
  • Keeps the renderer/DOM initialization behavior while eliminating the unused variable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/suite/dispose.js Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jonobr1
jonobr1 merged commit 9977407 into dev Apr 6, 2026
4 checks passed
@jonobr1
jonobr1 deleted the alert-autofix-56 branch April 6, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants