Reputation: 2391
I would like to create org.joda.time.DateTime with current time + 10 sec. Now I use this code:
DateTime testTime = new DateTime();
testTime = testTime.plusSeconds(10);
But Sonar generates Dodgy - Dead store to local variable violation. I suppose that the problem is the instantiating of DateTime in first step because in the second step it is overwritten with a new instance (because plusSeconds
method creates copy).
How to solve this? Is there some best practice - e.g. avoid the creation of two instances ("create current time and add same time in one step")?
Upvotes: 0
Views: 663