Skip to content

[java] UnusedPrivateMethod FP with Junit 5 @MethodSource #1175

@AustinShalit

Description

@AustinShalit

Rule: UnusedPrivateMethod

Description: We should update the UnusedPrivateMethod to look for and not flag JUnit 5 parameterized test method sources. Although these methods are not being used by our code, junit is using them.

Code Sample demonstrating the issue:

  private static Stream<Arguments> basenameKeyArguments() { // Violation!
    return Stream.of(
        Arguments.of("simple", "simple"),
        Arguments.of("simple", "one/two/many/simple"),
        Arguments.of("simple", "//////an/////awful/key////simple")
    );
  }

  @ParameterizedTest
  @MethodSource("basenameKeyArguments")
  void basenameKeyTest(final String expected, final String testString) {
    assertEquals(expected, NetworkTable.basenameKey(testString));
  }

Metadata

Metadata

Assignees

Labels

a:false-positivePMD flags a piece of code that is not problematic

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions