These calls cannot possibly be redundant because they both exit the method meaning there can never be a situation where both of them execute.
The actual example is a Builder pattern where thing.doIt() is more like Thing.builder().....build()
and it is incorrect to declare a Thing.ThingBuilder thingBuilder = Thing.builder() and reuse it all over the place (without invoking thingBuilder().clear() before each reuse) which is what this checker would have one do,
These calls cannot possibly be redundant because they both exit the method meaning there can never be a situation where both of them execute.
The actual example is a Builder pattern where
thing.doIt()
is more likeThing.builder().....build()
and it is incorrect to declare aThing.ThingBuilder thingBuilder = Thing.builder()
and reuse it all over the place (without invokingthingBuilder().clear()
before each reuse) which is what this checker would have one do,