-
Notifications
You must be signed in to change notification settings - Fork 288
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
FreezingArchRule generates file missing newline #1057
Comments
I agree, I've also stumbled over this several times and was annoyed 😒 Originally the file wasn't thought to be public API so I didn't put too much thought into the concrete layout, since I thought it would only be read programmatically anyway. I'd be happy to accept a PR, or I can also do it in time for the next release 🙂 |
And yeah, your solution sounds reasonable 👍 Don't see any pitfalls as long as reading the lines again accounts for it (which it might already do anyway 🤷♂️) |
For a file to be considered a text file, it needs to end with a newline character. Previously, ArchUnit did not add the final newline, which broke Git diff and other tools. Additionally, remove unnecessary list allocation: 1 when reading and 1 when writing a violation store file. Resolves TNG#1057
For a file to be considered a text file, it needs to end with a newline character. Previously, ArchUnit did not add the final newline, which broke Git diff and other tools. Additionally, remove unnecessary list allocation: 1 when reading and 1 when writing a violation store file. Resolves TNG#1057 Signed-off-by: Piotr Kubowicz <piotr.kubowicz@gmail.com>
For a file to be considered a text file, it needs to end with a newline character. Previously, ArchUnit did not add the final newline, which broke Git diff and other tools. Additionally, remove unnecessary list allocation: 1 when reading and 1 when writing a violation store file. Resolves TNG#1057 Signed-off-by: Piotr Kubowicz <piotr.kubowicz@gmail.com>
For a file to be considered a text file, it needs to end with a newline character. Previously, ArchUnit did not add the final newline, which broke Git diff and other tools. Additionally, remove unnecessary list allocation: 1 when reading and 1 when writing a violation store file. Resolves TNG#1057 Signed-off-by: Piotr Kubowicz <piotr.kubowicz@gmail.com>
For a file to be considered a text file, it needs to end with a newline character. Previously, ArchUnit did not add the final newline, which broke Git diff and other tools. Additionally, remove unnecessary list allocation: 1 when reading and 1 when writing a violation store file. Resolves #1057
To reproduce:
archunit_store/
git show
git show
\ No newline at end of file
(step 4)Additionally, well-behaving editors like vim or IntelliJ put newline character at the end of text files. This is because a file without final newline is not a proper text file. Anyway, as result, if you manually edit generated file (step 5), you generate a fake change in the last line by inserting the missing newline (step 6). Run ArchUnit test again, and you will play ping-pong with Git, doing nonsense changes to the last line.
Suggested solution: Change
com.tngtech.archunit.library.freeze.ViolationStoreFactory.TextFileBasedViolationStore#write
and stopjoin
ing violations with"\n"
. Just append\n
after each violation and all will be fine.I can open a PR if you don't have time to fix, just let me know you're fine with the solution.
The text was updated successfully, but these errors were encountered: