I’m getting this code smell in SonarQube "the return value of "format" must be used".
Sample code:
ShiftStartDate.format(DateTimeFormatter.ofPattern("MMddyyy")
ShiftEndDate.format(DateTimeFormatter.ofPattern("MMddyyyy")):
I tried, but I’m not sure what to return.
>Solution :
format is not mutating the Date, but rater returns a new String with the provided pattern. Sonarqube is telling you, that you do nothing with the return value. So either assign it to a variable, which you will use or remove the invocations altogether.