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] ImmutableField reports fields annotated with @Captor (Mockito) · Issue #3998 · pmd/pmd

[java] ImmutableField reports fields annotated with @Captor (Mockito) #3998

New issue
Copy link
New issue
Copy link
Closed
#4002
Closed
[java] ImmutableField reports fields annotated with @Captor (Mockito)#3998
#4002
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.47.0

Description

@zman0900
zman0900
opened on May 31, 2022
Issue body actions

Affects PMD Version:
6.46.0

Rule:
ImmutableField
https://pmd.github.io/pmd-6.46.0/pmd_rules_java_design.html#immutablefield

Description:
#3874 is not completely fixed with PMD 6.46.0. For example, fields annotated with Mockito's @Captor. Likely also effects other Mockito annotations such as @Spy.

Code Sample demonstrating the issue:

@ExtendWith(MockitoExtension.class)
class SomeTest {
    @Captor
    private ArgumentCaptor<String> argCaptor;
    @Mock
    private List<String> mockList;

    @Test
    void testCap() {
        mockList.add("junk");
        verify(mockList).add(argCaptor.capture());
        assertEquals("junk", argCaptor.getValue());
    }
}

Expected outcome:

PMD reports a violation for argCaptor, but that's wrong. That's a false positive.

Running PMD through:
Maven

Activity

  1. zman0900
    added
    a:false-positivePMD flags a piece of code that is not problematic
    on May 31, 2022
  2. adangel commented on Jun 2, 2022

    @adangel
    adangel
    on Jun 2, 2022
    Member
    More actions

    See also #3981

  3. adangel
    added this to the 6.47.0 milestone on Jun 7, 2022
  4. adangel
    closed this as completedin #4002on Jun 8, 2022
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.47.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.