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
Java Eclipse Adoptium (64-bit)
Mac OS X 12.3.1 x86_64

1 Like


Welcome to the community!

What version of SonarQube are you using?