You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#2160 (comment) Affects PMD Version:
6.20.0 Rule:
LawOfDemeter. Description:
Thread.currentThread() and ThreadLocalRandom().current() calls must be exempted from the method chaining and local object creation flagging by this rule. These calls and objects returned are thread-specific and for all practical purposes are pseudo-static properties.
You can add ProcessHandle.current() as another API call to be treated similarly.
- Fixespmd#2175
- Fixespmd#2179
- Fixespmd#1605: same fix as pmd#2179, since enum constants are static fields they are trusted.
- Fixespmd#2180: the fix is not to special-case Thread, but to consider all static methods as trusted (consistent with the treatment of static fields in pmd#2179)
- Fixespmd#2182: the fix is not to allow package-private access, but to allow a class to access fields of instances of the same class.
- Fixespmd#1014
- Fixespmd#2188
adangel
changed the title
[Java] False positive: LawOfDemeter is not cognizant of Thread and ThreadLocalRandom's special status.
[java] LawOfDemeter: False positive with Thread and ThreadLocalRandom
Feb 25, 2022
#2160 (comment)
Affects PMD Version:
6.20.0
Rule:
LawOfDemeter.
Description:
Thread.currentThread() and ThreadLocalRandom().current() calls must be exempted from the method chaining and local object creation flagging by this rule. These calls and objects returned are thread-specific and for all practical purposes are pseudo-static properties.
You can add ProcessHandle.current() as another API call to be treated similarly.
Code Sample demonstrating the issue:
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
The text was updated successfully, but these errors were encountered: