GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Error Prone
  • Bug Patterns
  • Docs
  • GitHub

This view

  • Original page
  • New address

GeezerVison is showing errorprone.info — RedundantSetterCall

RedundantSetterCall
A field was set twice in the same chained expression.

Severity
ERROR
Tags
FragileCode

Alternate names: ProtoRedundantSet

The problem

Proto and AutoValue builders provide a fluent interface for constructing instances. Unlike argument lists, however, they do not prevent the user from providing multiple values for the same field.

Setting the same field multiple times in the same chained expression is pointless (as the intermediate value will be overwritten), and can easily mask a bug, especially if the setter is called with different arguments.

return MyProto.newBuilder()
    .setFoo(copy.getFoo())
    .setFoo(copy.getBar())
    .build();

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("RedundantSetterCall") to the enclosing element.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.