V6091. Suspicious getter/setter implementation. The 'A' field should probably be returned/assigned instead.

The analyzer has detected a getter/setter that accesses a field different from the one mentioned in the name.

Such errors usually result from inattention or inaccurate use of autocomplete or copy-paste.

Consider the following example:

public class Vector2i
{
  private int x;
  private int y;

  public void setX(int x)
  {
    this.x = x;
  }
  public int getX()
  {
    return x;
  }

  public void setY(int y)
  {
    this.y = y;
  }
  public int getY()
  {
    return x;              // <=
  }
}

Fixed code:

public class Vector2i
{
  private int x;
  private int y;

  public void setX(int x)
  {
    this.x = x;
  }
  public int getX()
  {
    return x;
  }

  public void setY(int y)
  {
    this.y = y;
  }
  public int getY()
  {
    return y;
  }
}

To implement methods like that, it is better to use the means provided by the IDE or code generation provided by the Lombok library.


Bugs Found

Checked Projects
414
Collected Errors
14 218
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →
Accept