Branch: refs/heads/main
  Home:   https://github.com/pmd/pmd
  Commit: 6ff6e72ec293dae3f8bb7634126a56deccb3a5b4
      https://github.com/pmd/pmd/commit/6ff6e72ec293dae3f8bb7634126a56deccb3a5b4
  Author: Eljees <[email protected]>
  Date:   2026-08-08 (Sat, 08 Aug 2026)

  Changed paths:
    M docs/pages/release_notes.md
    M 
pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/CloseResourceRule.java
    M pmd-java/src/main/resources/category/java/errorprone.xml
    M 
pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/CloseResource.xml

  Log Message:
  -----------
  [java] CloseResource: allow Mockito mocks by default (#6954)

* [java] CloseResource: allow Mockito mocks and spies by default

* Address review: drop spy from the defaults, move the release note

@zbynek: a spy delegates to the real object by default, so the object it
wraps still has to be closed. Allowing Mockito#spy would have turned a true
positive into a false negative, so it is out of the defaults; only
Mockito#mock stays. The rule doc now says why spy and mockStatic are
deliberately absent.

The spy test case is removed rather than inverted. With spy out of the
defaults the rule reports 0 violations for it either way - the snippet took
the resource as a method parameter, so the case never discriminated on the
allowed-pattern list and was not testing what its description claimed. The
mock and mockStatic cases do discriminate and stay.

@UncleOwen: release note entry moved from java to java-errorprone.



To unsubscribe from these emails, change your notification settings at 
https://github.com/pmd/pmd/settings/notifications


_______________________________________________
Pmd-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pmd-commits

Reply via email to