Skip to content

FreezingArchRule generates file missing newline #1057

Closed
@pkubowicz

Description

To reproduce:

  1. use FreezingArchRule
  2. run ArchUnit test to let the rule generate file in archunit_store/
  3. commit the file to Git repository
  4. see the diff using git show
  5. open the file in IntelliJ, make any change (remove a random line), save, commit
  6. 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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions