Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mdt-papyrus.dev] Generated Code Formatting Policy

Hi, Team,

What is our policy vis-a-vis formatting of generated code?  Is it

  • don't format the code:  let GMF/Xtend just produce whatever it produces, or
  • format the generated source tree using your own preferred formatting style, or
  • format the generated source tree using the Papyrus Formatter Profile

Naturally, I would vote for the last option to ensure consistency.  :-)

I ask because I changed the DiagramUpdater template on a branch to change how it finds inverse cross-references and regenerated the class diagram, then formatted the code with the formatter profile from

doc/DevelopperDocuments/templates/Papyrus Formatter profile.xml

in the git repository.  The result was 576 files changed only by differences in the formatting, not the substance.

While we're on the subject, I often see commits that have lots of changes only in formatting (conforming to the above-mentioned profile).  I have so far resisted configuring the JDT's "save action" for formatting the file because I didn't want to introduce noisy changes into git, instead only formatting the locality of each of my edits.  It would be nice just to let the editor automatically format everything so that we can gradually converge on a uniformly formatted codebase, assuming (of course) that every committer does the same, with the same formatting profile!  Shall we agree to do this?  Or are there other recommendations?

There is also the question of git's line-terminator settings.  Those of us that are not on Windows platform often see CRLF line-terminations in the Papyrus source files.  I, for one, follow the (historically) recommended practice of setting my global gitconfig to core.autocrlf=input on Mac.  Does everybody on the team that uses Windows have the same core.autocrlf setting?  (regardless whether it's false, true, or input, though usually Windows users set it to true)

Git has since evolved its line-terminator management strategy using a .gitattributes file in the repository to ensure that teams will have a consistent story for that repo, as described here:


However, I don't think that EGit/JGit supports this mechanism (see https://wiki.eclipse.org/EGit/FAQ#How_compatible_is_EGit_with_Git.3F for more), so it wouldn't help unless everybody is like me and doesn't use EGit.

Thanks,

Christian


Back to the top