Closed todd-a-jacobs closed 1 year ago
That's interesting. I've always intentionally added the trailing whitespace. That's been convention on all of my code :sweat_smile:
@jwoertink / @todd-a-jacobs I'd recommend that this issue gets taken up with the Ameba team since we use their default rules and they expect a trailing blank line (I think):
This certainly seems like a valid reason to change the default, but I think the Ameba team will have more knowledge about the trade-offs.
Good call. Thanks @stephendolan
A lot of folks insist on adding a blank line to the end of files, you're not alone in that. I can't find an example but I'm sure that I've seen github drop an emoji in a diff which doesn't have a final blank line in it.
Git 2.36.1 still warns you at some points too, so it seems like the ecosystem is probably not consistent even within git. I got this warning today from a git commit -p
workflow: "\ No newline at end of file"
Edit: see also https://stackoverflow.com/questions/2287967/why-is-it-recommended-to-have-empty-line-in-the-end-of-a-source-file
I don't think it really matters to me, except for using as many sane defaults as possible. If people are going to get nagged about it when they start from scratch install of git and lucky, it's worth changing.
I'd recommend that this issue gets taken up with the Ameba team since we use their default rules and they expect a trailing blank line (I think).
From what I can tell, the default rule is to have a trailing newline character (e.g. the final line ends with \n
) rather than having trailing empty lines. This seems to be either something tweaked in the Ameba rules configured for the project, or someone just decided to add them despite the fact that trailing blank lines should be triggering an Ameba error.
All of the default Lucky content comes from here, with Ameba running via GitHub Actions on each PR: https://github.com/luckyframework/lucky_cli
It doesn't seem to be failing currently, but if you'd like to submit a PR to that repo to tweak this, I don't think anyone would be opposed to merging if it passes the default Ameba linter!
Looking at that Ameba linter, that's an opt-in feature, not opt-out it seems. So if you didn't want that, you'd create the ameba .ameba.yml
file, and configure it there. I don't think we will change this on our end unless Ameba does decide to make this a default.
I'm gonna close this out, but if anyone has a solid reason for the benefits of changing this, I'm still open to discussion.
Describe the bug When running
lucky init
, the wizard creates a number of files with trailing whitespace. With the standard defaults for core.whitespace in Git v2.36.1 (and likely other versions) attempting to commit the results oflucky init
will generate a number of errors.To Reproduce
lucky init
foo
.cd foo
git add .
git commit -av
This will result in errors from Git's default core.whitespace, and returns the following:
Expected behavior The default templates created by the wizard should not have:
Versions (please complete the following information):
Lucky version (check in shard.lock):
0.30.0
Crystal version (
crystal --version
):OS: macOS 11.6.7
Additional context
Git whitespace options, both default and custom:
Git whitespace-related config options:
Relevant ~/.gitconfig options:
Enabled
.git/hooks/pre-commit
hook within the project directory (doesn't test for whitespace issues):