How do we avoid the issue 'dateIndex' is not modified in this loop when using the setDate method?

SonarQube does not detect the modifier method of the Date object.
In that case, how to avoid “‘dateIndex’ is not modified in this loop” blocker bug issue without code change.

Sample Code:

while (dateIndex<endDate) {  
                .....
                .......
                ........
                dateIndex.setDate(dateIndex.getDate() + 1);
            }

Our environment:
SonarQube - 9.4 Build 54424
SonarScanner 4.7.0.2747
Java 11.0.14.1 Eclipse Adoptium (64-bit)
Mac OS X 12.3.1 x86_64

Hi,

Welcome to the community!

What version of SonarQube are you using?

 
Ann