mebigfatguy / fb-contrib

a FindBugs/SpotBugs plugin for doing static code analysis for java code bases
http://fb-contrib.sf.net
GNU Lesser General Public License v2.1
157 stars 45 forks source link

False Positive for PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS #444

Open feckertson opened 1 year ago

feckertson commented 1 year ago
public Whatever doIt() {
.....
  return thing.doIt();
....
 return thing.doIt(); //genrates PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS
}

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,