A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/2188 below:

False positive with fields assigned to local vars · Issue #2188 · pmd/pmd · GitHub

#2160 (comment)
Affects PMD Version:
6.20.0.

Rule:
LawOfDemeter.

Description:
Assigning an instance or local variables (created locally) should not be flagged as an object created elsewhere by this rule.

Code Sample demonstrating the issue:

package pmdtests;

public class AddressUsingCopyOnWrite {
  private volatile AddressValue addressValue;

 public AddressUsingCopyOnWrite(String       street, String city, String phone) {
   this.addressValue = new                    AddressValue(street, city, phone);
   }
  

 // thread-safe method
 @Override
  public String toString() {
    AddressValue local = addressValue;
    return "street=" + local.getStreet() + ",city=" + local.getCity()
        + ",phoneNumber=" + local.getPhoneNumber();
  }

 
}

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4