Description
To reproduce:
- use FreezingArchRule
- run ArchUnit test to let the rule generate file in
archunit_store/
- commit the file to Git repository
- see the diff using
git show
- open the file in IntelliJ, make any change (remove a random line), save, commit
- see the diff using
git show
- Expected: nice Git diff
- Actual: FreezingArchRule generates a file that shows in Git diff as
\ 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 stop join
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.