jeff-tyl
(Jeff Meyers)
May 5, 2023, 2:40pm
1
Windows 10, Eclipse 2023-03, SonarLint 7.10.0.68588, Java 17
Problem: false positive S2629 on Record getters.
Code Example:
public record r(String name) { }
...
log.debug("The name is: {}", r.name());
r.name()
is flagged for S2629, but it is essentially a getter for the record.
Hello @jeff-tyl ,
Thanks for your message. Indeed, this code feels like a valid one, so I created a ticket to fix it:
https://sonarsource.atlassian.net/browse/SONARJAVA-4474
However, there is still a corner case, if the getter is overridden and does some expensive computations. Anyway, I don’t feel like that is a common practice.
Regards,
Margarita
1 Like