Skip to content

Inline method calls should keep method select if required #7549

@timtebeek

Description

@timtebeek

Problem

We ran

  - org.openrewrite.java.InlineMethodCalls:
      methodPattern: org.apache.maven.index.AbstractSearchResponse getTotalHits()
      replacement: getTotalHitsCount()

Expected behavior

I expected red.getTotalHitsCount(), not getTotalHitsCount() in locations where originally a method select was present, and is still required.

Example diff

From: indexer-core/src/test/java/org/apache/maven/index/NexusIndexerTest.java

      totalHits++;
}

-        line = "### TOTAL:" + totalHits + " (response said " + res.getTotalHits() + ")";
+        line = "### TOTAL:" + totalHits + " (response said " + getTotalHitsCount() + ")";

if (print) {
System.out.println(line);
IteratorSearchResponse response = indexer.searchIterator(request);

-        assertEquals(2, response.getTotalHits());
+        assertEquals(2, getTotalHitsCount());

for (ArtifactInfo ai : response.getResults()) {
assertEquals("qdox", ai.getGroupId(), "GroupId must match \"qdox\"!");
IteratorSearchResponse response = indexer.searchIterator(request);

-        assertEquals(2, response.getTotalHits());
+        assertEquals(2, getTotalHitsCount());

assertTrue(response.getResults().hasNext(), "Iterator has to have next (2 found, 1 filtered out)");

Recipes in example diff:

  • org.openrewrite.java.InlineMethodCalls

References:

  • View original result
  • Recipe ID: org.openrewrite.java.InlineMethodCalls
  • Recipe Name: Inline method calls
  • Repository: apache/maven-indexer/master
  • Created at Sun May 03 2026 13:33:58 GMT+0200 (Central European Summer Time)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions