Enhance code readability and maintainability by applying consistent formatting practices throughout your codebase: 1. Properly indent continuation lines (lines that are part of the same statement as the preceding line)
Enhance code readability and maintainability by applying consistent formatting practices throughout your codebase:
For complex conditionals, prefer nested if statements over lengthy, hard-to-parse single-line conditions:
// Hard to read:
if ((AWS.HttpClient.streamsApiVersion !== 2) ||
(!(operation.hasEventOutput && service.successfulResponse(resp)) &&
(!stream || !stream.didCallback)))
// More readable:
if (!stream || !stream.didCallback) {
// don't concat response chunks when using event streams unless response is unsuccessful
if ((AWS.HttpClient.streamsApiVersion === 2) && operation.hasEventOutput && service.successfulResponse(resp)) {
return;
}
// proceed with regular processing
}
Consistent formatting makes code easier to scan, understand, and maintain, reducing the cognitive load for everyone working with the codebase.
Enter the URL of a public GitHub repository