error-prone icon indicating copy to clipboard operation
error-prone copied to clipboard

fix: support implicit `@MethodSource` to `UnusedMethod`

Open JarvisCraft opened this issue 6 months ago • 4 comments

Currently, UnusedMethod check does not recognize implicitly referenced JUnit @MethodSource, e.g. the ones which are derived from test method name when none are specified explicitly. This PR fixes this issue.

Fixes #5289

JarvisCraft avatar Aug 28 '25 13:08 JarvisCraft

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Aug 28 '25 13:08 google-cla[bot]

Hi @cushon, @graememorgan; could you please run the CI on this PR?

JarvisCraft avatar Oct 21 '25 12:10 JarvisCraft

nice plz include @After also this is kind of a general topic having to watch many actually all? junit annotations.

There will be new stuff to come for sure.

right @marcphilipp?

thank you.

  • https://github.com/opensearch-project/OpenSearch/pull/19896
  • https://github.com/opensearch-project/OpenSearch/blob/46164b5b678d3be68d04446d186ae429c7544d13/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java#L1369
  • https://github.com/opensearch-project/OpenSearch/actions/runs/19101079871/job/54572915387?pr=19896
/home/runner/work/OpenSearch/OpenSearch/test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java:1370: error: [UnusedMethod] Method 'cleanupReleasables' is never used.
    private void cleanupReleasables() {

Pankraz76 avatar Nov 05 '25 12:11 Pankraz76

@Pankraz76 @After is from JUnit 4 and such methods must be public.

marcphilipp avatar Nov 05 '25 13:11 marcphilipp