The squid: S2384 sonar rule causes a problem with this code:
public Date getCreatedOn() {
return createdOn;
}
following the Mutable rule, members should not be stored or returned directly
I understand that we should not return the original, instead we should return a copy of the object.
Sonar, on the other hand, does not cause a problem with this code:
public Date getCreatedOn() {
return this.createdOn;
}
What is the difference between this code?
Will we not return the original copy in the second case?
source
share