Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3734

FP in S5979 when "ExtendWith" annotation is coming from a meta-annotation

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.15
    • Component/s: Rules
    • Labels:
      None

      Description

      When "ExtendWith" annotation is coming from a meta-annotation, S5979 will report an issue despite the fact that this code will behave correctly.

      @ExtendWith(SpringExtension.class)
      @ExtendWith(MockitoExtension.class)
      public @interface SetupItTest
      {
      }
      
      @SetupItTest
      class UserControllerTest {
          @Captor private ArgumentCaptor<String> someCaptor; // FP
      }
      

      In addition, we should make sure that @MockitoSettings, a meta-annotation provided by mockito, is also supported.

      @MockitoSettings
      class UserControllerTest {
          @Captor private ArgumentCaptor<String> someCaptor; // FP
      }
      

      This should work without any specific effort, since this annotation is itself annotated with @ExtendWith(MockitoExtension.class).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.jaquier Quentin Jaquier
                Reporter:
                quentin.jaquier Quentin Jaquier
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: