Problems with SonarCloud

95 Views Asked by At

I am getting an error that I can't get past of. SonarCloud checks the code before it is merged into develop. This is the error that I am getting: enter image description here

I have included the return statement eventhough it can be implicit in the .map method, but just to satisfy SonarCloud and guess where it expects the return statement to be.

I have ran out of options here, and still don't know what's going on.

My original code was this:

return Promise.all(devicesList.map((device, idx) => (device.last_scheduled_id ? updateAction({ ...device, scheduled_at, current: idx }) : customAction({ ...device, scheduled_at, current: idx })))) .then(() => { setTimeout(() => { success("Scheduled successfully", { sticky: false }); setConfirmButton({ disabled: false, loading: false }); }, 2000); return setTimeout(() => { onClose(); dispatch(onHydrateTableData(true)); }, 3000); });

I have modified the code block in as many ways as possible, but still can't figure it out.

1

There are 1 best solutions below

0
On BEST ANSWER

It's hard to tell without context. Have you tried:

return await Promise.all(
  devicesList.map((device, idx) => {
    if (device.last_scheduled_id) {
      return updateAction({ ...device, scheduled_at, current: idx });
    }
    return customAction({ ...device, scheduled_at, current: idx });
  }),
);

If your code is behaving as expected and you think SonarCloud is making a mistake, provided that you have access to the SonarCloud organization and sufficient permissions, you can manually resolve the issue, which should allow you to merge into development. Here is a screenshot of the specific place where you can resolve issues:

Screenshot

Once you select a resolution reason, you are able to write a comment to justify it.