René's URL Explorer Experiment


Title: Fix the imports before the layout or after it? · Issue #224 · openjavaformat/open-java-format · GitHub

Open Graph Title: Fix the imports before the layout or after it? · Issue #224 · openjavaformat/open-java-format

X Title: Fix the imports before the layout or after it? · Issue #224 · openjavaformat/open-java-format

Description: The question Should the imports be fixed before the code is laid out, or after it? Every route has to do it in the same order, or the same file comes out differently (#219). #220 makes them all fix the imports after formatting, as the co...

Open Graph Description: The question Should the imports be fixed before the code is laid out, or after it? Every route has to do it in the same order, or the same file comes out differently (#219). #220 makes them all fix...

X Description: The question Should the imports be fixed before the code is laid out, or after it? Every route has to do it in the same order, or the same file comes out differently (#219). #220 makes them all fix...

Opengraph URL: https://github.com/openjavaformat/open-java-format/issues/224

X: @github

direct link

Domain: redirect.github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fix the imports before the layout or after it?","articleBody":"### The question\n\nShould the imports be fixed before the code is laid out, or after it? Every route has to do it in the same order, or the same file comes out differently (#219). #220 makes them all fix the imports after formatting, as the command line, the native binary and the GitHub Action already did. google-java-format has just gone the other way: google/google-java-format@633ce6be (2026-10-20) runs unused-import removal, modifier reordering and import sorting as one pass before the layout, on the command line too, and remaps the requested character ranges through each of its edits.\n\n### What depends on the order\n\n`ImportOrderer` moves a comment along with its import, and `RemoveUnusedImports` leaves the comment of an import it removes behind, so the order decides where that comment ends up. It also decides whether an extraneous semicolon between imports is dropped or fails the file. Over 3,865 real files, as they are and with an unused import added to each, the two orders differ in one, `CharsetEncoder` of JDK 21; each order passes its check on what the other wrote. Four cases, ready for `test-cases/imports` in #225, pin the differences: `commentOfARemovedImportGoesWithTheImportAboveIt`, `commentOfARemovedOwnPackageImportGoesWithTheImportAboveIt`, `commentUnderARemovedImportStaysOnTheClass` and `semicolonAfterTheLastImportStaysOnALineOfItsOwn`.\n\n### For and against\n\n| | **Before the layout** (google-java-format now, `formatSourceAndFixImports` before #220) | **After the layout** (#220, the command line, the native binary, the GitHub Action) |\n|---|---|---|\n| Output of the command line and the GitHub Action | changes in the rare cases above | stays as it is |\n| Porting from google-java-format | follows its `Cleanups` | conflicts with it |\n| `import a.B;;` followed by another import | formatted: `ImportOrderer` drops the semicolon | fails with `extraneous semicolon`, as javac 21 does with `--release 21` |\n| A comment under a removed import | a blank line stays between it and the class | stays on the class |\n| Reformat Code with \"Optimize imports\" in IntelliJ IDEA (#222) | the same order: the IDE runs the optimizer first | differs, unless a whole-file Reformat runs in one pass |\n| Ranges (`--lines`, `--output-replacements`, IntelliJ IDEA, `formatDiff`) | the ranges have to be remapped through the import edits, as google-java-format does | the ranges are offsets into the input and work as they are |\n| Work | `ImportOrderer` and `RemoveUnusedImports` return replacements instead of text; the import commit of #220 is redone | done in #220 |\n\n### Proposal\n\nKeep \"after\" for now: the command line is what every check compares with, and it does not change. Revisit when porting google-java-format's `Cleanups`, which would bring \"before\" together with the range remapping it needs.\n","author":{"url":"https://github.com/abashev","@type":"Person","name":"abashev"},"datePublished":"2026-11-13T20:36:08Z","url":"https://github.com/openjavaformat/open-java-format/issues/224"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e5363dbd-e1ea-9e9a-ff9d-14a3aa347e01
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAF52:12B577:22875:2E21E:6AFBD808
html-safe-nonce983940bc284344e0b71c75f26e8c6d59934c0805ca5091acc063ada73375c9ab
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjUyOjEyQjU3NzoyMjg3NToyRTIxRTo2QUZCRDgwOCIsInZpc2l0b3JfaWQiOiI1NTM5NTYyMjEyMTYwMTY1ODk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac2a5b7253e2897cbe9d22fd330b04fa3a7878b4936f73bbc00abbfa48c70de625
hovercard-subject-tagissue:6379511346
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/openjavaformat/open-java-format/224/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e8ffc6aee54be65d2f933c238ef0696c64e5778a1f777918877f3a8fb407dd04/openjavaformat/open-java-format/issues/224
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e8ffc6aee54be65d2f933c238ef0696c64e5778a1f777918877f3a8fb407dd04/openjavaformat/open-java-format/issues/224
og:image:altThe question Should the imports be fixed before the code is laid out, or after it? Every route has to do it in the same order, or the same file comes out differently (#219). #220 makes them all fix...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameabashev
hostnamegithub.com
expected-hostnamegithub.com
None18742cb872ec73544356e60359266b67aafece70c4ce008042e06227924cdd07
turbo-cache-controlno-preview
go-importgithub.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git
octolytics-dimension-user_id325177626
octolytics-dimension-user_loginopenjavaformat
octolytics-dimension-repository_id1288055459
octolytics-dimension-repository_nwoopenjavaformat/open-java-format
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forktrue
octolytics-dimension-repository_parent_id214273098
octolytics-dimension-repository_parent_nwopalantir/palantir-java-format
octolytics-dimension-repository_network_root_id214273098
octolytics-dimension-repository_network_root_nwopalantir/palantir-java-format
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release820be804f18e1ef3940bd74a00d41d73d02e2b91
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://redirect.github.com/openjavaformat/open-java-format/issues/224#start-of-content
https://redirect.github.com/
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fissues%2F224
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fissues%2F224
Sign uphttps://redirect.github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=openjavaformat%2Fopen-java-format
Reloadhttps://redirect.github.com/openjavaformat/open-java-format/issues/224
Reloadhttps://redirect.github.com/openjavaformat/open-java-format/issues/224
Reloadhttps://redirect.github.com/openjavaformat/open-java-format/issues/224
openjavaformathttps://redirect.github.com/openjavaformat
open-java-formathttps://redirect.github.com/openjavaformat/open-java-format
Codehttps://redirect.github.com/openjavaformat/open-java-format
Issues30 (30)https://redirect.github.com/openjavaformat/open-java-format/issues
Pull requests5 (5)https://redirect.github.com/openjavaformat/open-java-format/pulls
Discussionshttps://redirect.github.com/openjavaformat/open-java-format/discussions
Actionshttps://redirect.github.com/openjavaformat/open-java-format/actions
Security and qualityhttps://redirect.github.com/openjavaformat/open-java-format/security
Insightshttps://redirect.github.com/openjavaformat/open-java-format/pulse
https://redirect.github.com/openjavaformat/open-java-format
New issuehttps://redirect.github.com/login?return_to=https://github.com/openjavaformat/open-java-format/issues/224
New issuehttps://redirect.github.com/login?return_to=https://github.com/openjavaformat/open-java-format/issues/224
Fix the imports before the layout or after it?https://redirect.github.com/openjavaformat/open-java-format/issues/224#top
questionFurther information is requestedhttps://github.com/openjavaformat/open-java-format/issues?q=state%3Aopen%20label%3A%22question%22
https://github.com/abashev
abashevhttps://github.com/abashev
on Nov 13, 2026https://github.com/openjavaformat/open-java-format/issues/224#issue-6379511346
#219https://github.com/openjavaformat/open-java-format/issues/219
#220https://github.com/openjavaformat/open-java-format/pull/220
google/google-java-format@633ce6behttps://github.com/google/google-java-format/commit/633ce6be
#225https://github.com/openjavaformat/open-java-format/issues/225
#220https://github.com/openjavaformat/open-java-format/pull/220
#220https://github.com/openjavaformat/open-java-format/pull/220
#222https://github.com/openjavaformat/open-java-format/issues/222
#220https://github.com/openjavaformat/open-java-format/pull/220
#220https://github.com/openjavaformat/open-java-format/pull/220
abashevhttps://redirect.github.com/abashev
questionFurther information is requestedhttps://redirect.github.com/openjavaformat/open-java-format/issues?q=state%3Aopen%20label%3A%22question%22
on Nov 13, 2026https://github.com/openjavaformat/open-java-format/issues/224#event-36071740025
Sign up for freehttps://redirect.github.com/signup?return_to=https://github.com/openjavaformat/open-java-format/issues/224
Sign in to commenthttps://redirect.github.com/login?return_to=https://github.com/openjavaformat/open-java-format/issues/224
questionFurther information is requestedhttps://github.com/openjavaformat/open-java-format/issues?q=state%3Aopen%20label%3A%22question%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.