Use proxy reporting endpoint to subscribe to blocked events#328
Use proxy reporting endpoint to subscribe to blocked events#328SanderDeclerck wants to merge 5 commits intorama-integration-betafrom
Conversation
packages/safe-chain/src/registryProxy/builtInProxy/createBuiltInProxyServer.js Show resolved Hide resolved
| } | ||
| | ||
| function stop() { | ||
| return /** @type {Promise<void>} */ (new Promise((resolve) => { |
There was a problem hiding this comment.
Complex Promise executor is anonymous; extract into a named function to clarify behavior and make it easier to test.
Details
✨ AI Reasoning
A Promise executor was added that contains multiple statements: it checks state, sets a timeout, calls server.close with a callback, and resolves. This groups control-flow and resource-cleanup logic inside an anonymous function, which hides behavior and makes unit testing or reuse harder. Naming or extracting this logic would clarify purpose and improve maintainability.
🔧 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
| * @param {http.RequestListener} requestListener | ||
| * @returns {Promise<{server: http.Server, address: string}>} | ||
| */ | ||
| function startServer(requestListener) { |
There was a problem hiding this comment.
startServer's purpose is ambiguous (generic name duplicates other startServer functions). Rename to make it explicit (e.g., startReportingServer) so callers and readers understand this starts the reporting HTTP endpoint.
Details
✨ AI Reasoning
A developer should be able to determine what a function does from its name and context. The newly added function named startServer accepts a generic requestListener and returns a Promise resolving a server and an address. The repository already contains other startServer functions (e.g., in createBuiltInProxyServer) and the generic name makes it unclear whether this starts the reporting endpoint specifically or performs other responsibilities. While the file context implies it's for the reporting server, the identical generic name increases cognitive load and risks confusion when reading call sites or searching the codebase.
🔧 How do I fix it?
Use descriptive verb-noun function names, add docstrings explaining the function's purpose, or provide meaningful return type hints.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
Summary by Aikido
🚀 New Features
⚡ Enhancements
🔧 Refactors
More info