Having an issue with a bug smell in my code while using Sonar. The problem lies in the redundancy of incrementing the variable i++ within each if statement block. Looking for suggestions on how to refactor this code more efficiently:
private getDetailedUsageUrl(startDate: string, endDate: string, trafficType: string){
this.logsProvider.debugLog(this.logTag, 'getDetailedUsageUrl');
let url = this.detailedUsageServiceUrl;
let i = 3;
if (startDate !== null){
url += 'startDate=$' + i;
i++;
}
if(endDate !== null){
url += '&endDate=$' + i;
i++;
}
if (trafficType !== null){
url += '&trafficType=$' + i;
i++;
}
return url;
}