Skip to content

Newline behaviour of the LicenseHeaderManager

FlorianDecker edited this page Mar 8, 2017 · 6 revisions

Before 1.7.3, the LicenseHeaderManager (LHM) had some weird bugs with newlines (see bug #62 and #59). With the new 1.7.3 patch, we want a consistent and defined behaviour concerning the interaction of LHM with already existent newlines. Sadly we cannot retain empty lines on top of the file or between a skipped expression and the file, because when updating or removing the licenseheader, we never know if these empty lines are part of the header or not.

  • Rule 1: When adding a licenseheader to a file already containing a comment on top, LHM ensures that there is exactly 1 empty line between the newly added licenseheader and the comment on top. This is, to be able to define when the automatic updated licenseheader managed by LHM ends.
    • Rule 1.1: If the licenseheader defined in the .licenseheader file contains one or more empty lines at the end of the header, there will be exactly that amount of empty lines present on top of the file. If there exists a comment on top of the file, no extra empty line will be added.
  • Rule 2: When removing the licenseheader, all empty lines on top of the file are deleted.
  • Rule 3: When adding a licenseheader to a file containing empty lines at the top, these empty lines will be deleted.
  • Rule 4: When encountering Skipped Expressions, the content after the Skipped Expression are considered as "on top of the file" and empty lines are handled according to the rules above.