Doubt regarding code review For Public Apps

When I pack my app, I could see two warnings in the terminal which are shown below.


These warnings are shown because of the functions which are having more conditional statements. But this is the first time, we are handling each and every error based on their status code.


My question is because of these warnings, will it reject the app in the code review?
If it is yes, then I should clear these warnings by breaking them into another function.

1 Like

Hi @Sheik,

The app will not get rejected. Too many warnings will result in rejection. Two warnings should be fine.

Validator warnings are for your own benefit. The app has to be maintained by the publisher for years and publish frequent updates for improvements and bug fixes. This will help maintain the code cleaner and reduce the bug surface to narrow-down the issues easily in the future.

In your case, instead of using a switch case which will hit the bottom for performance, an object can be used with statusCode as key and error message as the value.

const errorMessageMap = { 400: '', 404: '' ...... , 500: '' };
function constructErrorObject(statusCode) {
  return new CustomErrors(errorMessageMap[statusCode] || 'Something went wrong. Please try again');
}
4 Likes