[SERVER-55281] restore lint enforcement of newlines at EOF for source files Created: 17/Mar/21 Updated: 29/Oct/23 Resolved: 25/Mar/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | None |
| Fix Version/s: | 5.0.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Billy Donahue | Assignee: | Billy Donahue |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Sprint: | Service Arch 2021-03-22, Service Arch 2021-04-05 | ||||||||||||
| Participants: | |||||||||||||
| Description |
|
A newline is a LF,CR,or CRLF, but we specifically want to enforce Unix LF newlines to avoid diff churn and other patching/tools issues. (Update: Git is handling the Windows-vs-Unix (CRLF-vs-LF) issue pretty well and no action needs to be taken in the linter for that) Lack of terminating newline affects the real results of scripting tools like cat and wc -l (line count), and is a source of diff/git churn. It's also something compilers can warn about, as such source files are technically not valid text files as defined by POSIX (they are now tolerated by C++11, but why push our luck). We used to check for this until the linter was rewritten in 2019. To identify these files:
Easiest fix is probbaby to append an empty echo.
Added a note to https://wiki.corp.mongodb.com/display/HGTC/Visual+Studio+Code+for+Server+Development |
| Comments |
| Comment by Githook User [ 25/Mar/21 ] |
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}Message: |
| Comment by Githook User [ 25/Mar/21 ] |
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@gmail.com', 'username': 'BillyDonahue'}Message: |
| Comment by Louis Williams [ 18/Mar/21 ] |
Unfortunately, yes. But it seems like there is a way to work around this. I misunderstood the purpose of this ticket. This ticket aims to add missing terminating newlines to files. It does not try to enforce specific LF usages throughout files, which Git already does. |
| Comment by Billy Donahue [ 18/Mar/21 ] |
|
The linter I'm talking about doesn't fix anything. Does VSCode produce invalid text files that don't have the terminating newline? The CRLF translation is already handled by git, I think. |