Frama-C / headache

Lightweight tool for managing headers in source code files. It can update in any source code files (OCaml, C, XML et al).
Other
24 stars 7 forks source link

Question about new empty line in header starting in 1.08 #8

Open mbarbin opened 1 month ago

mbarbin commented 1 month ago

Hello,

Thanks for headache! I've mentioned your project in the acknowledgment section of https://github.com/mbarbin/vcs but I take this opportunity to thank you directly for this tool!

I tried re-running headache in my project after upgrading to headache.1.08 and noticed the tool now wants me to add a blank line at the end of all headers. For example, see : https://github.com/mbarbin/vcs/blob/main/lib/vcs/src/author.ml

  (*******************************************************************************)
  (*  Vcs - a versatile OCaml library for Git interaction                        *)
  (*  Copyright (C) 2024 Mathieu Barbin <mathieu.barbin@gmail.com>               *)
  (*                                                                             *)
  (*  This file is part of Vcs.                                                  *)
  (*                                                                             *)
  (*  Vcs is free software; you can redistribute it and/or modify it under       *)
  (*  the terms of the GNU Lesser General Public License as published by the     *)
  (*  Free Software Foundation either version 3 of the License, or any later     *)
  (*  version, with the LGPL-3.0 Linking Exception.                              *)
  (*                                                                             *)
  (*  Vcs is distributed in the hope that it will be useful, but WITHOUT ANY     *)
  (*  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  *)
  (*  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and    *)
  (*  the file `NOTICE.md` at the root of this repository for more details.      *)
  (*                                                                             *)
  (*  You should have received a copy of the GNU Lesser General Public License   *)
  (*  and the LGPL-3.0 Linking Exception along with this library. If not, see    *)
  (*  <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively.       *)
+ (*                                                                             *)
  (*******************************************************************************)

Is this intended? I don't feel strongly, if you think this is better practice, I'm OK to adopt the new format, I was just curious. From the perspective of a user like me, this changes feels surprising.

Thanks!

maroneze commented 1 month ago

Hello,

Indeed, this is surprising, but I'm afraid this behavior is intentional, at least partially: https://github.com/Frama-C/headache/commit/49bac32732f404ef737578462218e4c2b4f942fc

The issue we had was that, since modern code editors tend to remove extraneous empty lines at the end of a file without warning, when updating the copyright year, some colleagues inadvertently ended up removing the extra line. To prevent that from happening, we added the "mandatory empty last line".

In the Frama-C header files, for "aesthetic reasons", I believe, we almost always have an empty line before the first one, so the empty line after the last one improves symmetry (even if there are a few exceptions, such as this one).

If that behavior is problematic to you, I'll see what might be the simplest way to support the previous behavior; we'd like to avoid adding command-line options if possible, they tend to add much complexity and require extra testing...

(I said the behavior was at least partially intended because we simply did not consider the case of a header file not starting with an empty line.)

mbarbin commented 1 month ago

Thank you! I don't want to be needlessly difficult, I'm not sure what to think.

(I said the behavior was at least partially intended because we simply did not consider the case of a header file not starting with an empty line.)

Would you be opposed to restrict the automatic addition of an extra blank line at the end, by conditioning it to the presence of a first leading blank line? (trying to find a common ground that allows no behavior change for me).

maroneze commented 1 month ago

That's precisely what I intended to do, and it would only impact a single file in Frama-C. But I'm waiting for my colleague to check if he foresees other problems; if you're not in a hurry, next week we should have a reply and possibly a patch.

mbarbin commented 1 month ago

I'll be using 1.07 for now - no time pressure from me. Thanks a lot!