Conversation
1d2a96a to
667d41e
Compare
change-type: patch Signed-off-by: fisehara <harald@balena.io>
667d41e to
d636a5b
Compare
| const proxy = new URL(proxyUrl); | ||
|
|
||
| // Create the tunnel first using CONNECT | ||
| const socket = await new Promise<import('node:net').Socket>( |
There was a problem hiding this comment.
Anonymous Promise callback contains multi-step proxy CONNECT logic; extract into a named function to improve readability and testability.
Details
✨ AI Reasoning
A Promise constructor is created with an anonymous callback that performs multi-step logic: building proxyRequestOptions, handling proxy auth, issuing http.request and wiring 'connect', 'error', and 'timeout' handlers, and resolving/rejecting based on socket events. This is more than a trivial callback and hides business logic inside an unnamed function, making testing and comprehension harder. Extracting this logic into a named function would improve clarity and testability.
🔧 How do I fix it?
Extract complex anonymous functions into named functions with descriptive names, or add explanatory comments for their purpose.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
No description provided.