This repository was archived by the owner on Aug 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
This repository was archived by the owner on Aug 2, 2025. It is now read-only.
Refactor Error Aggregation for Missing Parameters #37
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
The current implementation of error aggregation for missing parameters in the codebase involves concatenating missing field names, which can lead to extra spaces or punctuation. This approach can be improved for better maintainability and clarity by using an array to collect missing keys and then joining them into a string.
Suggested Improvement:
Instead of concatenating strings directly, use an array to gather all missing parameters and then join them with a separator. This method not only enhances readability but also reduces the risk of formatting errors.
Proposed Code:
let missingParams: string[] = [];
if (!body.compose_spec) {
missingParams.push("compose_spec");
}
if (!body.automatic_reboot_on_error) {
missingParams.push("automatic_reboot_on_error");
}
if (!body.source) {
missingParams.push("source");
}
if (!body.name) {
missingParams.push("name");
}
if (missingParams.length > 0) {
const errMsg = `Missing values of: ${missingParams.join("; ")}`;
return responseHandler.error(set, errMsg, errMsg);
}Action Items:
- Refactor the existing code to implement the suggested improvement.
- Ensure that any further usage of the error message variable is updated accordingly if it depended on the previous concatenation approach.
This change will improve the maintainability and clarity of the error handling code.
I created this issue for @Its4Nik from #33 (comment).
Tips and commands
Interacting with Sourcery
- Generate a plan of action: Comment
@sourcery-ai planon this issue. - Generate a pull request for this issue: Comment
@sourcery-ai developto
generate a PR that addresses this issue.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request