Can someone help me understand why SonarQube is flagging this error and suggest a resolution?
The unnecessary cast should be removed.
Promise.all([
this.customerViewCmr4tProvider.getData(activeNumber),
this.customerBillManagementProvider.getData(individualPublicId, billingAccountId, false),
this.agreementProvider.getData(this.activeCustomerServiceProvider.getPhoneNumber(), this.activeCustomerServiceProvider.getCmsProfile()
)]
)
.then(
(results) => {
let customerViewRootCrm4tModel = new CustomerViewRootCrm4tModel();
let customerBillModel = new CustomerBillRootModel();
let agreementRoot = new AgreementRoot();
if (results[0] instanceof CustomerViewRootCrm4tModel) {
customerViewRootCrm4tModel = results[0] as CustomerViewRootCrm4tModel;
}
if (results[1] instanceof CustomerBillRootModel) {
customerBillModel = results[1] as CustomerBillRootModel;
}
if (results[2] instanceof AgreementRoot) {
agreementRoot = results[2] as AgreementRoot;
}
const numberDevices = this.customerViewCmr4tProvider.getProductByActiveNumber(customerViewRootCrm4tModel, activeNumber).length;
const lastBill = this.customerBillManagementProvider.getLastCustomerBill(customerBillModel).amountDue.value;
const agreement = this.getAgreementMonthsLeft(agreementRoot);
this.sendGoogleAnalyticsPageView(numberDevices.toString(), agreement, lastBill);
},
() => {
// error
this.sendGoogleAnalyticsPageView("", "", null);
}
);