Skip to content

Commit 2225f9c

Browse files
committed
Convert if else statements to if() statements that return
1 parent 0caf494 commit 2225f9c

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

components/quickbooks/sources/common.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ module.exports = {
112112
const webhookCompanyId = event.body.eventNotifications[0].realmId;
113113
if (!this.isValidSource(event, webhookCompanyId)) {
114114
console.log("Skipping event from unrecognized source.");
115-
} else {
116-
await Promise.all(entities.map((entity) => {
117-
entity.realmId = webhookCompanyId;
118-
return this.validateAndEmit(entity);
119-
}));
115+
return;
116+
}
117+
118+
await Promise.all(entities.map((entity) => {
119+
entity.realmId = webhookCompanyId;
120+
return this.validateAndEmit(entity);
121+
}));
120122
}
121123
},
122124
};

components/quickbooks/sources/custom-webhook-events/custom-webhook-events.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ module.exports = {
3131
// (it would a hassle for the user to select every option if they wanted to emit everything)
3232
if (this.namesToEmit.length > 0 && !this.namesToEmit.includes(entity.name)) {
3333
console.log(`Entity Type '${entity.name}' not found in list of selected Entity Types`);
34-
} else if (this.operationsToEmit.length > 0
34+
return;
35+
}
36+
if (this.operationsToEmit.length > 0
3537
&& !this.operationsToEmit.includes(entity.operation)) {
3638
console.log(`Operation '${entity.operation}' not found in list of selected Operations`);
37-
} else {
38-
await this.processEvent(entity);
39-
}
39+
return;
40+
}
41+
await this.processEvent(entity);
4042
},
4143
},
4244
};

components/quickbooks/sources/new-or-modified-customer/new-or-modified-customer.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ module.exports = {
3535
// if they wanted to emit everything)
3636
if (entity.name !== sourceEntity) {
3737
console.log(`${entity.name} webhook received and ignored, since it is not a Customer`);
38-
} else if (this.operationsToEmit.length > 0
38+
return;
39+
}
40+
if (this.operationsToEmit.length > 0
3941
&& !this.operationsToEmit.includes(entity.operation)) {
4042
console.log(`Operation '${entity.operation}' not found in list of selected Operations`);
41-
} else {
42-
await this.processEvent(entity);
43+
return;
4344
}
45+
await this.processEvent(entity);
4446
},
4547
},
4648
};

0 commit comments

Comments
 (0)