Repository navigation
chore: shorten fully-qualified type names via OpenRewrite - #2673
Open
maxandersen wants to merge 2 commits into
Open
maxandersen wants to merge 2 commits into
maxandersen wants to merge 2 commits into
Conversation
Contributor
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
maxandersen
force-pushed
the
build/openrewrite-shorten-fqn
branch
2 times, most recently
from
October 7, 2026 07:45
42609a5 to
21773a7
Compare
maxandersen
force-pushed
the
build/openrewrite-shorten-fqn
branch
3 times, most recently
from
October 7, 2026 09:28
ab60c11 to
40e7580
Compare
maxandersen
marked this pull request as ready for review
October 7, 2026 09:29
maxandersen
force-pushed
the
build/openrewrite-shorten-fqn
branch
2 times, most recently
from
October 7, 2026 09:38
e52ecb5 to
0a9be76
Compare
…ng gate Add the org.openrewrite.rewrite plugin wired to the ShortenFullyQualifiedTypeReferences recipe (shortens inline fully-qualified type names to simple names + imports, resolved from the compile classpath). - rewrite.yml: no-star ImportLayoutStyle (jbang forbids wildcard imports) - exclude *.gradle (OpenRewrite's Groovy shortening drops needed imports) - failOnDryRunResults = true so rewriteDryRun fails on FQN drift - 'format'/'formatCheck' run OpenRewrite + Spotless together (Spotless after) - check depends on formatCheck; build/release jobs use '-x check' - docs/tooling: CONTRIBUTING.adoc, AGENTS.md and the justfile 'format' recipe now use 'gradle format'/'formatCheck' Apply with './gradlew format'.
Output of './gradlew rewriteRun' - shorten fully-qualified type names to simple names + imports across the module. Pure type-preserving rewrite.
maxandersen
force-pushed
the
build/openrewrite-shorten-fqn
branch
from
October 7, 2026 09:39
0a9be76 to
c4071a4
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I tried making spotless do removal of Fully qualified names that LLM's has an annoying tendency to include - but spotless does not use a type aware formatter so it misses too much. this pr uses openrewrite to properly check for it.
Also introduces a dedicated format and formatCheck gradle task - does make formatting slightly slower but its "just" compile which you need to do 99% of the time anyway.
Summary
Introduce OpenRewrite with the
ShortenFullyQualifiedTypeReferencesrecipe to replace inline fully-qualified type names with simple names + imports, and apply it (25 files).plugins { id "com.diffplug.spotless" version "8.6.0" + id "org.openrewrite.rewrite" version "7.39.0" } +rewrite { + activeRecipe('org.openrewrite.java.ShortenFullyQualifiedTypeReferences') + activeStyle('dev.jbang.ImportStyle') // rewrite.yml: no wildcard imports + exclusion('*.gradle', 'settings.gradle', '**/*.gradle', '**/*.gradle.kts') +}Example of what it does:
Why OpenRewrite and not a formatter step? Unlike Spotless/CleanThat (which run without a classpath and must guess with heuristics), OpenRewrite builds a type-attributed model from the compile classpath, so it shortens safely across the whole module — including cases a classpath-free tool must leave alone (types in classes with an external superclass, method references on fields like
catalog.aliases::get, etc.).Evidence
ImportLayoutStyle), compiles clean, spotless-clean.catalog.aliases::get(a method reference on a field) correctly left untouched — OpenRewrite knowscatalogis a local variable.Merge Danger
Door: two-way. Pure type-preserving rewrite (FQN → simple name + import); trivially revertible, and re-runnable via
./gradlew rewriteRun.Blast Radius: wide but shallow — 25 source files touched, imports-only + name-only edits, no behavior change (compile + tests + spotless all green).
Notes:
*.gradleis excluded on purpose: OpenRewrite's Groovy support shortens stdlib types (e.g.groovy.json.JsonOutput) without adding the import, which breaks the Gradle script.7.39.0:7.40.0/7.41.0currently fail to resolve (they depend onrewrite-bom:8.91.0, not yet on Maven Central). Bump once it syncs../gradlew rewriteDryRun(not added here).