Skip to content
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

Add GitHub action to automatically add EOL @ EOF #4485

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JLLeitschuh
Copy link
Contributor

According to how the posix standard defines a line

3.206 Line
A sequence of zero or more non- characters plus a terminating character.

Thus, many of the files in this repository that don't contain a newline at the end of the file contain a file where the last line isn't, according to the spec actually a line.

Screen Shot 2020-10-15 at 11 52 38 AM

This GitHub action resolves this issue by automatically adding a End of Line (EOL) @ End of File (EOF).

@hmakholm
Copy link
Contributor

I wonder if fixing that automatically is desirable in the first place. Among the things this repo contains are test cases for the language extractors. It feels plausible that we'd want some of the test inputs to lack terminating newlines, such that parsing and location reporting in those cases can be exercised.

@JLLeitschuh
Copy link
Contributor Author

You can specify an list of files to ignore in the config.

@JLLeitschuh JLLeitschuh requested a review from a team as a code owner March 16, 2023 22:21
Copy link
Contributor

@esbena esbena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by comments: this 2.5 year old PR has grown stale wrt. best Action practices.

@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/newline_pr_action branch from 221acc5 to 46dae63 Compare March 18, 2023 02:41
@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/newline_pr_action branch 2 times, most recently from 136e2f8 to 0fa88ee Compare March 20, 2023 18:41
@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/newline_pr_action branch from 0fa88ee to cccf2cb Compare March 21, 2023 15:47
@JLLeitschuh
Copy link
Contributor Author

@esbena PR has been updated to address concerns

@aibaars
Copy link
Contributor

aibaars commented Mar 22, 2023

One thing to note is that the POSIX is about portability across operating systems. It has nothing to do with programming language specifications. The questions of "what is a line" and even "what is a character" vary between programming languages. For example https://262.ecma-international.org/8.0/#table-33 . I'm all in favour of automatically formatting source files, and quite like having newline characters at the end of files. However, I'm not sure we want to enforce this.

Another things to note:

This action will automatically fix files without a final new line in pull requests.
Only works for UTF-8 files.

I think most of our files are UTF-8, so this shouldn't be too much of an issue.

@JLLeitschuh
Copy link
Contributor Author

The other thing that I notice is that, many IDEs or anyone that has an .editorconfig file in their root directory ends up adding the newline to files they modify when they create a PR changing a file. This means that the final newline getting added ends up being kinda random, and only happens to certain files modified by certain people.

By enforcing this org-wide will mean that it's finally consistent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants