-
Notifications
You must be signed in to change notification settings - Fork 114
System-default line separators are implicitly enforced despite lax configurations #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We had a recent pull-request to Spring Boot to add a |
Yeah. If my understanding is correct, that The
If this Edit: Here's an example of the formatting-related failures on a Windows runner after adding the |
@philwebb Could we add a bug label to this? |
I tinkered with my PoC a bit and reached a seemingly-working state, where a fresh clone builds without fuss (tested on Windows and Ubuntu): https://github.com/ParkerM/spring-javaformat/tree/preserve-eol 9f0173b adds some test fixtures for CR/LF/CRLF line endings by specifying them in .gitattributes files, borrowing from Checkstyle's approach. If there's any interest let me know and I'll open a PR. |
Context: I'm a Windows user that often builds Spring projects from source. My global
.gitconfig
setscore.autocrlf=input
because I want to avoid CRLF line endings by any means necessary. This clashes specifically with spring-javaformat, and makes it a huge pain to build any Spring project.Example output with spring-projects/spring-boot
I first assumed this had something to do with Checkstyle, but I do not believe this is the case, especially since the default
NewlineAtEndOfFileCheck
was relaxed to accept any trailing newline in 0b36c1c.Another contributor touched on the crux of the problem here:
It seems the discussion fell short once the issue was closed as fixed, but the fix only supports the "Windows user with CRLF line endings" case.
From what I've gathered, whenever a line separator is not explicitly specified, it is passed down as
null
to the internals of the EclipseTextEdit
stuff that occurs during the validate/format phases, wherein the default line separatornull
turns intoSystem.lineSeparator()
(which does not abide my git config).My proposal is to attempt to detect and pass along the line endings of each file before it is submitted to the whims of the Eclipse formatter. Essentially:
io.spring.javaformat.formatter.Formatter#format
is called withlineSeparator = null
source
by checking each line separator.this.delegate.format
.null
line separator tothis.delegate.format
by default.Here's a clumsy and un-tested whack at the impl I'm describing: ParkerM@92579ca
I'd be happy to create some repros via various CI runners and git configs, but will hold off until it's deemed necessary.
The text was updated successfully, but these errors were encountered: