Skip to content

Add S1185 recipe: Remove methods that only call super#837

Merged
timtebeek merged 7 commits intomainfrom
tim/remove-useless-super-call
Apr 15, 2026
Merged

Add S1185 recipe: Remove methods that only call super#837
timtebeek merged 7 commits intomainfrom
tim/remove-useless-super-call

Conversation

@timtebeek
Copy link
Copy Markdown
Member

Implements RSPEC-S1185 to detect and remove methods that override a parent method but only delegate to super with the same arguments. Methods are safe to remove only if they have no semantic annotations, no Javadoc, and don't widen visibility.

Includes 12 comprehensive test cases covering positive and negative scenarios.

Implements RSPEC-S1185 to detect and remove methods that override a parent
method but only delegate to super with the same arguments. Includes 12
comprehensive test cases covering positive and negative scenarios.
Consolidate triple-pass (count params, count args, match) into a single
pass that counts and matches simultaneously.
Final overrides intentionally prevent further subclass overriding,
so they should not be removed even if they only call super.
A @deprecated method that merely delegates to super is doubly redundant
and should be removed along with plain @Override-only methods.
Remove removeMethodWithOnlyOverrideAnnotation which duplicated existing
coverage. Add test verifying methods with semantic annotations like
@transactional are retained.
@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Apr 15, 2026
@timtebeek timtebeek merged commit c6ebfd4 into main Apr 15, 2026
1 check passed
@timtebeek timtebeek deleted the tim/remove-useless-super-call branch April 15, 2026 14:22
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants