A RetroSearch Logo

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

Search Query:

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

[java] LawOfDemeter: False positive with static property access

#2160 (comment)
Affects PMD Version:
6.20.0
Rule:
LawOfDemeter.
Description:
Static property access warning must not be flagged for Law of Demeter when it can be mitigated by static import. The access of a static property is double-counted; the dot accessor count must start from the static property, not the class in which it exists. A very special case for this would be the static property at the class level 'class'. This should be treated as a global variable as well.

Code Sample demonstrating the issue:

package pmdtests;
import java.util.concurrent.TimeUnit;
import static java.util.concurrent.TimeUnit.SECONDS;

public enum Test {
  ;

  public static void main(String[] args) {
    try {
     
        TimeUnit.MILLISECONDS.sleep(300);
SECONDS.sleep(2);
       
  
    } catch (InterruptedException ie) {
      System.err.println(ie);
    }
  }
}

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