Skip to content

Commit

Permalink
Refactor builError function to reduce its Cognitive Complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-rr committed Feb 8, 2022
1 parent e99e4dc commit ca3196f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/errors/validation-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ export class ValidationError extends Error {
// Info added to 'errorsInfo' when both 'e.title' and 'e.location' are available
if (errorHasTitle && errorHasLocation) {
errorsInfo.push(`${e.title} ${e.location.startLine}:${e.location.startColumn}`);
continue;
}
// Info added to 'errorsInfo' when only 'e.title' is available
if (errorHasTitle && !errorHasLocation) {
if (errorHasTitle) {
errorsInfo.push(`${e.title}`);
continue;
}
// Info added to 'errorsInfo' when only 'e.location' is available
if (!errorHasTitle && errorHasLocation) {
if (errorHasLocation) {
errorsInfo.push(`${e.location.startLine}:${e.location.startColumn}`);
}
}
}

this.message = errorsInfo.join('\n');
}
}

0 comments on commit ca3196f

Please sign in to comment.