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

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] LawOfDemeter: False positive with 'this' pointer · Issue #2174 · pmd/pmd

[java] LawOfDemeter: False positive with 'this' pointer #2174

New issue
Copy link
New issue
Copy link
Closed
#2560
Closed
[java] LawOfDemeter: False positive with 'this' pointer#2174
#2560
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.26.0

Description

@linusjf
linusjf
opened on Dec 19, 2019
Issue body actions

#2160 (comment)

Affects PMD Version:
6.20.0

Rule:
LawOfDemeter

Description:
LawOfDemeter does not recognise 'this' pointer and includes its dot accessor as a count towards method chaining. It must not. Similarly for 'super' while calling parent class functions.

Code Sample demonstrating the issue:

package pmdtests;

public class Foo {
  private final int i;

  public Foo(int i) {
    this.i = i;
  }


  public void meth() {
    System.out.println(this.i); // wrong violation: method chain calls
    System.out.println(super.i); // wrong violation: method chain calls
    System.out.println(i);      // no violation
  }

  public void method(Foo this) {
    System.out.println(this.i);  // wrong violation: method chain calls
  }

  public void method(Foo this, String... args) {
    System.out.println(this.i);  // wrong violation: method chain calls
    for (String arg: args)
      System.out.println(arg);
  }
}

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

Activity

  1. linusjf
    changed the title [-][java] Law of Demeter must ignore this pointer. False positive.[/-] [+][java] Law of Demeter must ignore 'this' pointer. False positive.[/+] on Dec 19, 2019
  2. adangel
    changed the title [-][java] Law of Demeter must ignore 'this' pointer. False positive.[/-] [+][java] LawOfDemeter: False positive with 'this' pointer[/+] on Dec 20, 2019
  3. adangel
    added
    a:false-positivePMD flags a piece of code that is not problematic
    on Dec 20, 2019
  4. adangel
    added a commit that references this issue on Jul 16, 2020

    [doc] Update release notes, refs pmd#2560, fixes pmd#2174, fixes pmd#…

    This issue will close once commit 836c272 is merged into the 'master' branch.
    836c272
  5. adangel
    added this to the 6.26.0 milestone on Jul 16, 2020
  6. adangel
    closed this as completedin 836c272on Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.26.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.